Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49AA9800D for ; Fri, 16 Sep 2011 00:31:59 +0000 (UTC) Received: (qmail 33603 invoked by uid 500); 16 Sep 2011 00:31:59 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 33563 invoked by uid 500); 16 Sep 2011 00:31:59 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 33546 invoked by uid 99); 16 Sep 2011 00:31:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2011 00:31:58 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [59.167.240.32] (HELO fish.ish.com.au) (59.167.240.32) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2011 00:31:52 +0000 Received: from ip-136.ish.com.au ([203.29.62.136]:56092) by fish.ish.com.au with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76) (envelope-from ) id 1R4MKx-0004vF-1W; Fri, 16 Sep 2011 10:31:24 +1000 X-CTCH-RefID: str=0001.0A150201.4E7298DC.0015,ss=1,re=0.000,fgs=0 Message-ID: <4E7298DB.2030808@maniatis.org> Date: Fri, 16 Sep 2011 10:31:23 +1000 From: Aristedes Maniatis User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: dev@cayenne.apache.org CC: user@cayenne.apache.org Subject: Re: Type safe queries & more References: <4E42DE88-4245-4573-BB24-7AF9649DD6A8@karlmenn.is> In-Reply-To: <4E42DE88-4245-4573-BB24-7AF9649DD6A8@karlmenn.is> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Hello Hugi Welcome to Cayenne. The work you have done is extremely welcome and has been discussed before: http://markmail.org/thread/nnnj2ezvpzamphdn 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 (github.com) 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 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 ); > fetch( ObjectContext, Expression ); > fetch( ObjectContext, Expression, List ); > 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