Re: Chainable SelectQuery

2015-04-27 Thread Andrus Adamchik
> Yeah, I don't know if changing setXyz to *not* return 'void' would > break things (like Tapestry). That would be a huge downer. Just saw something cool at WOWODC. Instead of changing setXyz to return "this", people would generate a Builder class for each Java class that has fluent methods for

Re: Chainable SelectQuery

2014-11-28 Thread Andrus Adamchik
> On Nov 29, 2014, at 4:09 AM, Aristedes Maniatis wrote: > > On 29/11/2014 1:01am, Andrus Adamchik wrote: >> Just added another flavor of select method - 'selectFirst'. Unlike >> 'selectOne' intended for queries that expect at most one row back, >> 'selectFirst' is a quick way to get the top-o

Re: Chainable SelectQuery

2014-11-28 Thread Aristedes Maniatis
On 29/11/2014 1:01am, Andrus Adamchik wrote: > Just added another flavor of select method - 'selectFirst'. Unlike > 'selectOne' intended for queries that expect at most one row back, > 'selectFirst' is a quick way to get the top-of-the-list object, even if the > query matched many objects. I.e.

Re: Chainable SelectQuery

2014-11-28 Thread Andrus Adamchik
Just added another flavor of select method - 'selectFirst'. Unlike 'selectOne' intended for queries that expect at most one row back, 'selectFirst' is a quick way to get the top-of-the-list object, even if the query matched many objects. I.e. it is equivalent to "limit(1).selectOne(context)". A

Re: Chainable SelectQuery

2014-11-19 Thread Andrus Adamchik
It is kind of hard for us to detect and prevent all possible conflicts in the *downstream* code like this. Hope this is not something that completely prevents the use of Cayenne with Scala though. Andrus > On Nov 17, 2014, at 7:59 PM, David Feshbach wrote: > > One possible reason to avoid "e

Re: Chainable SelectQuery

2014-11-17 Thread David Feshbach
One possible reason to avoid "eq" and "ne" is that they are already methods on Scala's AnyRef. When using Cayenne in Scala, I get errors like this in my IDE: > org.apache.cayenne.exp.Property[String] and String are unrelated: they will > most likely never compare equal On Nov 17, 2014, at 9:09 A

Re: Chainable SelectQuery

2014-11-17 Thread John Huss
I definitely do not want "is", especially since the the negated operation has to be consistent - "eq" and "ne" works. I like "where". I would stick with "select" since we have SQLSelect and ObjectSelect. Unless we have good alternatives names for those too. On Mon, Nov 17, 2014 at 8:42 AM, Andr

Re: Chainable SelectQuery

2014-11-17 Thread Andrus Adamchik
Cayenne Property class is using 'eq' for the same reason. > On Nov 17, 2014, at 5:07 PM, Mike Kienenberger wrote: > > Chainable fest testing assertions use "isEqualTo" to avoid confusion > with "equals" > > > On Mon, Nov 17, 2014 at 9:01 AM, Michael Gentry wrote: >> On Sun, Nov 16, 2014 at 9

Re: Chainable SelectQuery

2014-11-17 Thread Mike Kienenberger
Chainable fest testing assertions use "isEqualTo" to avoid confusion with "equals" On Mon, Nov 17, 2014 at 9:01 AM, Michael Gentry wrote: > On Sun, Nov 16, 2014 at 9:13 AM, Andrus Adamchik > wrote: >>> "eq" with "is", >> >> I actually prefer "eq[uals]". Considering all other operations in the

Re: Chainable SelectQuery

2014-11-17 Thread Michael Gentry
On Sun, Nov 16, 2014 at 9:13 AM, Andrus Adamchik wrote: >> "eq" with "is", > > I actually prefer "eq[uals]". Considering all other operations in the > Property class, "is" creates a bit of asymmetry IMO. The problem with "equals" is it has other connotations in Java, otherwise I'd like it just f

Re: Chainable SelectQuery

2014-11-16 Thread Aristedes Maniatis
On 17/11/2014 5:30pm, Andrus Adamchik wrote: > What is everyone's thought on "select" -> "find" change? I think "find" is slightly better than "select". But only slightly. Far more important is consistency and if we have a dozen other places where we still use 'select' terminology than we should

Re: Chainable SelectQuery

2014-11-16 Thread Andrus Adamchik
I am personally of the same opinion re: milestone API evolution. So we have "exp" -> "where" change, which I'll make. What is everyone's thought on "select" -> "find" change? Andrus > On Nov 17, 2014, at 3:00 AM, Aristedes Maniatis wrote: > > On 17/11/2014 1:13am, Andrus Adamchik wrote: >> I

Re: Chainable SelectQuery

2014-11-16 Thread Aristedes Maniatis
On 17/11/2014 1:13am, Andrus Adamchik wrote: > It depends. Most of the new API is very new and can be changed with no > consequences. Some was already present in 3.2M1 a year ago > (ObjectContext.select(..), Property). Still can change, but early adopters > will be affected. I'm a big +1 on bre

Re: Chainable SelectQuery

2014-11-16 Thread Andrus Adamchik
> On Nov 16, 2014, at 4:49 PM, Michael Gentry wrote: > Perhaps I've missed the boat on this one It depends. Most of the new API is very new and can be changed with no consequences. Some was already present in 3.2M1 a year ago (ObjectContext.select(..), Property). Still can change, but early ad

Re: Chainable SelectQuery

2014-11-16 Thread Michael Gentry
Hi Andrus, Perhaps I've missed the boat on this one (been too busy at work, etc), but I think it might be more readable to not abbreviate names and perhaps make it read more like a sentence. Given your example, perhaps something like: List artists = ObjectSelect.query(Artist.class) .where(Ar

Re: Chainable SelectQuery

2014-11-15 Thread Andrus Adamchik
> On Oct 11, 2014, at 4:06 AM, Andrus Adamchik wrote: > > 1. Instead of drastically redoing good old SelectQuery, we'll create a > separate class called ObjectSelect featuring fluent API. No deprecations in > SelectQuery. > [..] > Also cases when you need to reset/replace previous settings.

Re: Chainable SelectQuery

2014-10-18 Thread Andrus Adamchik
The first step in this direction is committed under CAY-1960. Now you can do this (with or without a static import) : import static org.apache.cayenne.exp.ExpressionFactory.*; and(E1.P1.eq("a"), E1.P2.ge(5), E1.P3.le(77)); or(E1.P1.eq("a"), E1.P2.ge(5)); // new positional binding exp(

Re: Chainable SelectQuery

2014-10-11 Thread Andrus Adamchik
On Oct 11, 2014, at 9:02 AM, Michael Gentry wrote: > On Fri, Oct 10, 2014 at 9:06 PM, Andrus Adamchik > wrote: >> 6. Corollary to #5, we should explore iterator methods in query chains (need >> to make sure that we don't reinvent the wheels invented in Java 8). > > Hi Andrus, > > I couldn't

Re: Chainable SelectQuery

2014-10-11 Thread Michael Gentry
On Fri, Oct 10, 2014 at 9:06 PM, Andrus Adamchik wrote: > 6. Corollary to #5, we should explore iterator methods in query chains (need > to make sure that we don't reinvent the wheels invented in Java 8). Hi Andrus, I couldn't tell from your #6 if you were saying we should be requiring Java 8's

Re: Chainable SelectQuery

2014-10-11 Thread Malcolm Edgar
I would strongly favor not impacting existing classes, but introduce a new fluent API or builder patterns. regards Malcolm On Sat, Oct 11, 2014 at 12:06 PM, Andrus Adamchik wrote: > I think this was a very productive discussion. Based on it and some more > thinking, here is my takeaway: > > 1.

Re: Chainable SelectQuery

2014-10-10 Thread Andrus Adamchik
I think this was a very productive discussion. Based on it and some more thinking, here is my takeaway: 1. Instead of drastically redoing good old SelectQuery, we'll create a separate class called ObjectSelect featuring fluent API. No deprecations in SelectQuery. In fact the existing API still

Re: Chainable SelectQuery

2014-10-10 Thread John Huss
I could go along with calling this 4.0 On Thu, Oct 9, 2014 at 5:15 PM, Michael Gentry wrote: > I think you are announcing Cayenne 4.0 ... :-) > > > On Thu, Oct 9, 2014 at 5:37 PM, Andrus Adamchik > wrote: > > Based on this discussion I am leaning towards leaving SelectQuery alone > (perhaps wit

Re: Chainable SelectQuery

2014-10-09 Thread Michael Gentry
I access my *data* objects all the time in Tapestry templates. Things such as firstName and lastName. The point I was trying to make is if setFirstName started returning the 'User' instance instead of 'void', it could possibly break some libraries out there (such as whatever Tapestry uses to proc

Re: Chainable SelectQuery

2014-10-09 Thread Robert Zeigler
It would only break tapestry of you were accessing properties of your query object from your template or via property expressions in bindings. So if your component had a limit property that was bound to the query's limit, then that might break. GATAATGCTATTTCTTTAACGAA > On Oct 9, 2014, at

Re: Chainable SelectQuery

2014-10-09 Thread Michael Gentry
I think you are announcing Cayenne 4.0 ... :-) On Thu, Oct 9, 2014 at 5:37 PM, Andrus Adamchik wrote: > Based on this discussion I am leaning towards leaving SelectQuery alone > (perhaps with changes already there, but no fluent builder methods and no > deprecation), as the impact on everybody

Re: Chainable SelectQuery

2014-10-09 Thread Andrus Adamchik
Based on this discussion I am leaning towards leaving SelectQuery alone (perhaps with changes already there, but no fluent builder methods and no deprecation), as the impact on everybody will be very big. And creating an alternative fluent ObjectQuery that will feature all the new stuff. Andrus

Re: Chainable SelectQuery

2014-10-09 Thread Mike Kienenberger
I wonder if QueryBuilder is a better approach which would preserve backwards compatibility. On Thu, Oct 9, 2014 at 3:08 PM, Michael Gentry wrote: > Yeah, I don't know if changing setXyz to *not* return 'void' would > break things (like Tapestry). That would be a huge downer. > > On Thu, Oct 9, 2

Re: Chainable SelectQuery

2014-10-09 Thread Michael Gentry
Yeah, I don't know if changing setXyz to *not* return 'void' would break things (like Tapestry). That would be a huge downer. On Thu, Oct 9, 2014 at 3:03 PM, Andrus Adamchik wrote: > I thought of that. Unfortunately "setXyz" is a 'java bean' setter, so we'll > be redefining one of the most esta

Re: Chainable SelectQuery

2014-10-09 Thread Andrus Adamchik
I thought of that. Unfortunately "setXyz" is a 'java bean' setter, so we'll be redefining one of the most established Java conventions. Andrus On Oct 9, 2014, at 2:51 PM, Michael Gentry wrote: > I don't know if it will be confusing or not. At least with the > current method names, I can type

Re: Chainable SelectQuery

2014-10-09 Thread Michael Gentry
I don't know if it will be confusing or not. At least with the current method names, I can type query.set[ctrl+space] and let Eclipse give me a list of set* method names to choose from (same applies for get*), but that option won't be available with the new chainable API. Part of me thinks just ma

Re: Chainable SelectQuery

2014-10-09 Thread Andrus Adamchik
On Oct 7, 2014, at 9:30 PM, Michael Gentry wrote: > On Tue, Oct 7, 2014 at 6:44 PM, Aristedes Maniatis wrote: >>> That said, if returning this is the direction we're going, then really all >>> the currently void methods in SelectQuery should do the same thing - like >>> addOrdering for example.

Re: Chainable SelectQuery

2014-10-08 Thread Robert Zeigler
On Oct 7, 2014, at 10/79:31 AM , John Huss wrote: > Hmm... I have a lot to say, so I might ramble a bit. > > 1) Static imports > > I'll never been a big user of static imports, largely because the tooling > (Eclipse) doesn't support them well. Everytime I've used a static import > (which is r

Re: Chainable SelectQuery

2014-10-08 Thread Andrus Adamchik
On Oct 7, 2014, at 7:41 PM, Aristedes Maniatis wrote: >> Yes both are valid. The point of the new one is that deeply nested >> expressions can not be easily built within a context of query, so you'd >> build them separately and then pass the final object to the query. So >> query.or/and(..) i

Re: Chainable SelectQuery

2014-10-08 Thread Andrus Adamchik
On Oct 7, 2014, at 7:41 PM, Aristedes Maniatis wrote: >>> >>> Can't we parse without any ambiguity: >>> >>> exp("artist.dateOfBirth < $date", c.getTime()); >> >> In case of a single parameter you are right. Good point! > > In the case of multiple parameters could we just as easily pass pa

Re: Chainable SelectQuery

2014-10-07 Thread Michael Gentry
On Tue, Oct 7, 2014 at 6:44 PM, Aristedes Maniatis wrote: >> That said, if returning this is the direction we're going, then really all >> the currently void methods in SelectQuery should do the same thing - like >> addOrdering for example. > > > Correct, but we also need to gracefully deprecate t

Re: Chainable SelectQuery

2014-10-07 Thread Aristedes Maniatis
On 7/10/2014 10:37pm, Andrus Adamchik wrote: >> Can't we parse without any ambiguity: >> >>exp("artist.dateOfBirth < $date", c.getTime()); > > In case of a single parameter you are right. Good point! In the case of multiple parameters could we just as easily pass parameters in order for a

Re: Chainable SelectQuery

2014-10-07 Thread Aristedes Maniatis
On 8/10/2014 1:31am, John Huss wrote: > I'm not a fan of methods that return "this" because it is impossible to > tell (without looking at javadoc) whether a new instance or the same > instance is returned. This pattern was named "fluent" by Martin Fowler. http://martinfowler.com/bliki/FluentIn

Re: Chainable SelectQuery

2014-10-07 Thread John Huss
Hmm... I have a lot to say, so I might ramble a bit. 1) Static imports I'll never been a big user of static imports, largely because the tooling (Eclipse) doesn't support them well. Everytime I've used a static import (which is really only in JUnit) I've wanted to import all the members: import

Re: Chainable SelectQuery

2014-10-07 Thread Andrus Adamchik
On Oct 6, 2014, at 8:00 AM, Aristedes Maniatis wrote: > On 6/10/2014 2:10am, Andrus Adamchik wrote: >> // a single chain from query to object list >> List paintings2 = SelectQuery.query(Painting.class, >> qualifier2).select(context); > > Since we already have a constructor with the appropriate

Re: Chainable SelectQuery

2014-10-06 Thread Aristedes Maniatis
On 6/10/2014 2:10am, Andrus Adamchik wrote: > // a single chain from query to object list > List paintings2 = SelectQuery.query(Painting.class, > qualifier2).select(context); Since we already have a constructor with the appropriate arguments, why not go for this as the recommended approach: