db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <...@Germuska.com>
Subject Re: Queries for M:N collections?
Date Sat, 04 Oct 2003 14:13:42 GMT
At 11:11 +0200 10/2/03, LAURENT Stephane wrote:
>you can getCollection of A where listOfA contain at lesat one 
>element equal to wantedAInstance :
>
>crit.addEqual("listOfA",wantedAInstance);
>getCollectionbyCriteria(A.class,crit);
>
>you can getCollection of A where listOfA contain at lesat one 
>element A having at least A in his listOfA collection :
>
>crit.addEqual("listOfA.listOfA",wantedAInstance);
>getCollectionbyCriteria(A.class,crit);

Yes, this is it.  To be honest, I went ahead and tried what seemed 
like the intuitive syntax before I saw your reply, and I was pleased 
to see it work.  Knowing now that it works, I can understand the 
approach the framework takes to building the SQL, but I was hung up 
on trying to imagine more pure property access.  That is, in my case, 
my query is something like this:

crit.addIn("items.categoryCode", categories)

Since "items" is a list, obviously it doesn't have a property 
"categoryCode".  Its members have that category, but at first I 
thought I would at least need to somehow specify an index -- i 
thought it might be something like
crit.addIn("items[*].categoryCode", categories)

Of course, now I see that OJB knows that "items" is a collection, not 
a field, and so it can interpret what comes after items 
(.categoryCode) differently than it would in a 1:1 join.

Thanks for your reply,
	Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
  "We want beef in dessert if we can get it there."
   -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message