db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Kruggel <li...@bbf7.de>
Subject Re: Queries for M:N collections?
Date Sat, 04 Oct 2003 09:55:49 GMT
Am Donnerstag Oktober 2 2003 11:11 schrieb LAURENT Stephane:
> Hi,
> I'm not sur to understand, but ...
> you have :
> Class A
> {
>     Integer idA;
>     String attribute1_A;
>     String attribute2_A;
> ..
>     Collection listOfA
> }
>
>
> if your repository is like this :
> <class-descriptor class="A" table="tableA">
>         <field-descriptor name="idA" column="ID" jdbc-type="BIGINT"
> primarykey="true" autoincrement="true"/> <field-descriptor 
> name="attribute1_A" column="a1" jdbc-type="VARCHAR"/>
> <field-descriptor name="attribute2_A" column="a2"
> jdbc-type="VARCHAR"/> ..
>         <collection-descriptor name="listOfA" element-class-ref="A"
> auto-retrieve="true" auto-update="true" indirection-table="tableA_A">
> <fk-pointing-to-this-class column="idA"/>
>             <fk-pointing-to-element-class column="idA"/>
>            </collection-descriptor>
>   </class-descriptor>
>
>
> 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);
>
> ..
>
> is it your goal ?
>   ----- Original Message -----
>   From: Joe Germuska
>   To: OJB Users List
>   Sent: Thursday, October 02, 2003 12:00 AM
>   Subject: Queries for M:N collections?
>
>   At 16:44 -0500 10/1/03, Joe Germuska wrote:
>   >I'm dealing with a case where I want to model an M:N relationship
>   >between two objects of the same type.  I have a collection
>   >descriptor modeled off of the example for this on the OJB site.
>   >When I go to store, I'm getting a class cast exception...
>
>   For what it's worth, changing that property to a Collection
>   definitely solved my problem.  Which leads me to the real question:
>
>   I need to construct a Query which selects collections for either
>   direction of this relationship.  That is, Given a parent, I need to
>   find all of its children, and given a child, I need to find all of
>   their possible parents.
>
>   I can probably work this out with a QueryBySQL, but I'm trying to
>   avoid that.  I don't see any methods on Criteria to set where I can
>   set something like "property contains some member"...  Can anyone
>   advise?
>
>   Thanks in advance,
>   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
>
>
>
>   ---
>   Outgoing mail is certified Virus Free.
>   Checked by AVG anti-virus system (http://www.grisoft.com).
>   Version: 6.0.522 / Virus Database: 320 - Release Date: 01/10/2003

cu

-- 
Roland Kruggel		mailto: liste@bbf7.de
System: AMD 1200Mhz, Debian woody, 2.4.20, KDE 3.1.4


---------------------------------------------------------------------
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