cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Type safe queries & more
Date Fri, 16 Sep 2011 06:53:53 GMT
Hi Hugi,

I second Ari on this. 

The ERXKeys were created well past my EOF days, but I saw the code based on it on a few projects
and it looked quite impressive. 

Type-safe queries are very high on the Cayenne priority list. Since we planned deeper internal
support of generics, I am expecting it will be fully done around 3.2 (we are now developing
3.1). However as you show, with some cgen magic current users can have some of it right away.

So yeah, if we are going to have more technical discussions re: integrating it in Cayenne
somehow, let's do it on the devl list.

And yes - welcome to Cayenne :)


On Sep 16, 2011, at 3:31 AM, Aristedes Maniatis wrote:
> Hello Hugi
> Welcome to Cayenne. The work you have done is extremely welcome and has been discussed
> It just is that no-one has had the time to work on it. This syntax is also very similar
to the way Ruby Rails queries are constructed: very clean and easy to read.
> I encourage you to do a couple of things to follow this through and see if we can get
this approach into Cayenne:
> 1. Take this over to the dev list (I'm copying that list in now)
> 2. Put your code somewhere. Jira is a very good option (no matter how basic the code
is) because you will agree to a license agreement releasing the code under the ASL which makes
it possible for us to include your code in Cayenne. You could also use something like gist
( to put code in a more visible place for now, but ultimately it will need to come
back through Jira.
> Again, welcome. Getting type safety into object keys has always been a goal here.
> Ari
> On 16/09/11 4:29 AM, Hugi Thordarson wrote:
>> Hi all.
>> Cayenne beginner here. I come from an EOF/WebObjects background, so when I started
using Cayenne (yesterday) I kinda missed the type safety and conciseness of using Mike Schrag's
ERXKeys when constructing qualifiers and Orderings.
>> So me and another EOF guy (@atlipall) sat down today and recreated/reverse-engineered
some of Mike's work to be usable with Cayenne. We're sharing this early, hoping it might be
useful for someone elseā€”and  since we're total beginners and don't know much about Cayenne
yet, comments are appreciated. (Perhaps we're even implementing pre-existing functionality;
we just don't know :).
>> Anyway, by using the two attached classes and superclass template, you can write
type safe code such as:
>> List<User>  users = User.fetch( dataContext, "joe%" ).and(
User.AGE.between( 20, 30 ), User.FIRSTNAME.asc().then( User.LASTNAME.asc() ) );
>> (this would fetch all users named "joe"-something, aged betweeen 20 and 30, and order
the list by first name, then last name.
>> We also added some convenience methods to the superclass template. These are:
>> fetchAll( ObjectContext );
>> fetchAll( ObjectContext, List<Ordering>  );
>> fetch( ObjectContext, Expression );
>> fetch( ObjectContext, Expression, List<Ordering>  );
>> fetchOne( ObjectContext, Expression );
>> create{relationship_name}Relationship();
>> delete{relationship_name}Relationship();
>> That's all for now.
>> Cheers,
>> - hugi
> -- 
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message