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, User.FIRSTNAME.like( "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

Reply via email to