You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Aristedes Maniatis <ar...@maniatis.org> on 2011/11/15 06:26:03 UTC

Re: Type safe queries & more

I just stumbled on another Java ORM which copies many ideas from Ruby Rails.

   http://code.google.com/p/activejdbc/

Some of the API concepts there are nice and similar to what is described below. It is Apache licensed, so there are no problems with us borrowing any class definitions if we find them useful. However they don't appear to have attempted any type safety at all.

Ari


On 16/09/11 7:35 PM, Aristedes Maniatis wrote:
> On 16/09/11 6:57 PM, Durchholz, Joachim wrote:
>> User.fetch( dataContext,
>> new Query(
>> User.FIRSTNAME.like( "joe%" )
>> .and(User.AGE.between( 20, 30 )))
>> .sort( User.FIRSTNAME.asc().then( User.LASTNAME.asc() )
>> )
>
> Another approach is to use the keys only as function parameters.
>
> User.where(User.FIRSTNAME, Query.LIKE, "joe%").and(User.AGE, Query.BETWEEN, "20,30").sort(User.FIRSTNAME, Query.ASC).sort(User.LASTNAME, Query.ASC).limit(10)
>
> or with strings:
>
> User.where("firstname LIKE joe%").and("age BETWEEN 20,30").sort("firstname ASC").sort("lastname ASC").limit(10)
>
>
> You could also pre-define qualifiers like this:
>
> debtors = User.where("owing > 0)
>
> and then later on use it in this nice natural speech kind of way:
>
> debtors.where("firstname LIKE joe%")
>
> All we need for this is to make .and() and .where() equivalent functions.
>
>
> Please reply to the dev@ list only.
>
> Thanks
> Ari
>

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A