<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: amoscatelli</title>
    <description>The latest articles on DEV Community by amoscatelli (@amoscatelli).</description>
    <link>https://dev.to/amoscatelli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F874681%2F974f180c-cb45-4419-a44d-850b5ef9e3c8.jpeg</url>
      <title>DEV Community: amoscatelli</title>
      <link>https://dev.to/amoscatelli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amoscatelli"/>
    <language>en</language>
    <item>
      <title>JNoSQL CriteriaQuery API preview</title>
      <dc:creator>amoscatelli</dc:creator>
      <pubDate>Thu, 09 Jun 2022 09:46:08 +0000</pubDate>
      <link>https://dev.to/amoscatelli/jnosql-criteriaquery-api-preview-4l7n</link>
      <guid>https://dev.to/amoscatelli/jnosql-criteriaquery-api-preview-4l7n</guid>
      <description>&lt;p&gt;Have you ever heard of &lt;a href="https://jakarta.ee/specifications/nosql/"&gt;Jakarta NoSQL&lt;/a&gt; ?&lt;/p&gt;

&lt;p&gt;Since JavaEE adoption and rebranding by &lt;a href="https://www.eclipse.org/"&gt;Eclipse Foundation&lt;/a&gt;, I consider it the most exciting feature for the upcoming Jakarta EE 10.&lt;/p&gt;

&lt;p&gt;By splitting the NoSQL databases in four different abstractions (&lt;strong&gt;Column&lt;/strong&gt;, &lt;strong&gt;Key-Value&lt;/strong&gt;, &lt;strong&gt;Graph&lt;/strong&gt; and &lt;strong&gt;Document&lt;/strong&gt;), it allows agnostic coding with such technologies. So, for example, you could access both MongoDB and ElasticSearch with the same codebase, for they are both categorized and exposed as &lt;strong&gt;Document&lt;/strong&gt; databases.  &lt;/p&gt;

&lt;p&gt;Cool, isn't it ?&lt;/p&gt;

&lt;p&gt;Personally, I already adopted it even if both specification and default implementation, &lt;a href="http://www.jnosql.org/"&gt;JNoSQL&lt;/a&gt;, are in preview state and may lack some functionalities.&lt;/p&gt;

&lt;p&gt;For example, I found myself struggling with the absence of a proper Criteria API, allowing us to build up a criteria query object programmatically, where we could apply different kinds of filtration rules and logical conditions.&lt;/p&gt;

&lt;p&gt;Also, following the JPA example, I would expect such Criteria API to be used in combination with an automatically generated Metamodel attributes.&lt;/p&gt;

&lt;p&gt;Typos and backend don't get on well, do they ?&lt;/p&gt;

&lt;p&gt;So I decided to contribute myself and, with the support of &lt;a href="https://otaviojava.com/"&gt;Otavio Santana&lt;/a&gt;, JNoSql Lead, this functionality has been delivered in the brand-new 1.0.0-b4 version.&lt;/p&gt;

&lt;p&gt;Looking for a concrete example ?&lt;br&gt;
Here you are :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CriteriaQuery&amp;lt;Person&amp;gt; personQuery = template.createQuery(Person.class);

EntityQueryResult&amp;lt;Person&amp;gt; executeQuery = template.executeQuery(
        personQuery.select().where(
                personQuery.from().get(
                        Person_.name
                ).equal(
                        "Poliana"
                ).or(
                        personQuery.from().get(
                                Person_.age
                        ).greaterThanOrEqualTo(17)
                )
        )
);

Stream&amp;lt;Person&amp;gt; stream = executeQuery.getEntities();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the moment, it has been published as a &lt;a href="https://github.com/eclipse/jnosql-mapping-extension/tree/master/mongodb-extension"&gt;MongoDB extension&lt;/a&gt; but, with the community approval and once it's stable enough, it will brought to the main API and will work with every other &lt;strong&gt;Document&lt;/strong&gt; NoSQL databases.&lt;/p&gt;

&lt;p&gt;There are still many features to add and possibilities to explore.&lt;br&gt;
For example, I strongly believe that Criteria API should also support update and delete operations too.&lt;br&gt;
Also, wouldn't it be nice to have this working with other NoSQL abstractions (&lt;strong&gt;Column&lt;/strong&gt;) ?&lt;/p&gt;

&lt;p&gt;What do you think ?&lt;/p&gt;

</description>
      <category>jakartaee</category>
      <category>nosql</category>
      <category>mongodb</category>
      <category>java</category>
    </item>
  </channel>
</rss>
