<p dir="ltr">wish: please try them in Eclipse too as sometimes the usage experience is not the same. </p>
<div class="gmail_quote">On 12 Jun 2013 18:05, &quot;Emmanuel Bernard&quot; &lt;<a href="mailto:emmanuel@hibernate.org">emmanuel@hibernate.org</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I forgot to say that fluent APIs in java are awesome but a nightmare to maintain backward compatibility wise. If you think building was hard, wait till you have to fix it or retrofit it.<br>
<br>
That is also why thinking about all possible future needs is important.<br>
<br>
Emmanuel<br>
<br>
On 12 juin 2013, at 17:44, Emmanuel Bernard &lt;<a href="mailto:emmanuel@hibernate.org">emmanuel@hibernate.org</a>&gt; wrote:<br>
<br>
&gt; A few comments in no particular order<br>
&gt;<br>
&gt; - nice work<br>
&gt; - try and cover all future possible extensions of the language to be<br>
&gt;  sure you are not heading to a trap<br>
&gt; - no cross type support<br>
&gt;  I suspect some kind of Union query could be useful<br>
&gt;  (from(User.class)....union().from(Dog.class)...)<br>
&gt; - projection<br>
&gt;  you must think about projection and aggregation from day one even if<br>
&gt;  you end up not offering it initially.<br>
&gt; - I&#39;m skeptical about contains* as I don&#39;t see much value in them as<br>
&gt;  they seem quite specific. Do they work beyond collection of native<br>
&gt;  types?<br>
&gt; - I can&#39;t see how you will write complex predicate compositions (nested<br>
&gt;  ands and ors) while keeping your elegant flow.<br>
&gt;  I suspect you need some external reference? From where?<br>
&gt;  That&#39;s usually where these styles of fluent APIs wo params fall<br>
&gt;  apart and why we went differently in JPA.<br>
&gt; - static method entry point<br>
&gt;  I suspect that using a static method entry point is a mistake.<br>
&gt;  Yes it looks simpler and more elegant than qb.from() but you also lose<br>
&gt;  any ability to have a context passed and used during the query<br>
&gt;  construction (like the CacheManager or whatever).<br>
&gt;  I could be wrong though as I haven&#39;t seen how you will execute the<br>
&gt;  query.<br>
&gt;<br>
&gt; Emmanuel<br>
&gt;<br>
&gt; On Fri 2013-06-07 18:56, Adrian Nistor wrote:<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; As per ISPN-3169 &quot;Define a Query API that will be common for library<br>
&gt;&gt; mode + remote&quot; we set out to define a simple dsl for writing queries<br>
&gt;&gt; against embedded and remote caches that should be agnostic to the<br>
&gt;&gt; actual engine that executes the query (lucene in our case now but<br>
&gt;&gt; might be others later) and yet be easy to be translated into the<br>
&gt;&gt; native query language of the said engine.<br>
&gt;&gt;<br>
&gt;&gt; Our dsl aims to support filtering cached entities:<br>
&gt;&gt;  * by attributes allowing equality and range filters (less than,<br>
&gt;&gt; greater than, between)<br>
&gt;&gt;  * some very simple collections tests (contains(value),<br>
&gt;&gt; containsAll(setOfValues), containsAny(setOfValues)) that can be<br>
&gt;&gt; applied to attributes that are collections of values<br>
&gt;&gt;  * string &#39;like&#39; operator similar to SQL<br>
&gt;&gt;  * &#39;in&#39; filter, to test if the attribute value belongs to a given<br>
&gt;&gt; fixed set of values<br>
&gt;&gt;  * The filters can be composed of subfilters connected by logical<br>
&gt;&gt; and/or operators. Operator precedence can be changed using nested<br>
&gt;&gt; subfilters.<br>
&gt;&gt;  * Negation is also allowed of course<br>
&gt;&gt;  * besides filtering based on attributes of the root entity it<br>
&gt;&gt; should also be able to filter on attributes of embedded entities<br>
&gt;&gt; (eg. person.address.postalCode == &quot;123&quot;) at any nesting level<br>
&gt;&gt;<br>
&gt;&gt; As for type safety, the dsl should not allow the user to build<br>
&gt;&gt; syntactically invalid queries.<br>
&gt;&gt; Having a dsl that is also typesafe with regard to the domain model<br>
&gt;&gt; is desirable, but not a must for this early stage.<br>
&gt;&gt;<br>
&gt;&gt; Here is a simple domain model I&#39;ve used for writing some sample queries.<br>
&gt;&gt;<br>
&gt;&gt;   // a typesafe version User $user = $(User.class);<br>
&gt;&gt;   Query q0 = from($user)<br>
&gt;&gt;   .having($user.getName()).eq(&quot;John&quot;)<br>
&gt;&gt;   .and()<br>
&gt;&gt;   .having($user.getAddress().getPostCode()).eq(&quot;NW123&quot;)<br>
&gt;&gt;   .build(); // non typesafe field references<br>
&gt;&gt;   Query q1 = from(User.class)<br>
&gt;&gt;   .having(&quot;name&quot;).eq(&quot;John&quot;)<br>
&gt;&gt;   .and()<br>
&gt;&gt;   .having(&quot;surname&quot;).eq(&quot;Doe&quot;)<br>
&gt;&gt;   .build(); More query samples on github here:<br>
&gt;&gt;   <a href="https://github.com/anistor/infinispan/blob/t_3169_m/query/src/main/java/org/infinispan/query/sandbox/sample_domain_model/QuerySamples.java" target="_blank">https://github.com/anistor/infinispan/blob/t_3169_m/query/src/main/java/org/infinispan/query/sandbox/sample_domain_model/QuerySamples.java</a><br>

&gt;&gt;   This is just an interface sketch, not an implementation. Your<br>
&gt;&gt;   thoughts and comments regarding this dsl are very welcome! I&#39;ll add<br>
&gt;&gt;   all of the above to the wiki too. Cheers<br>
&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</blockquote></div>