You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Michael Duffy <du...@yahoo.com> on 2003/03/20 22:24:34 UTC

How to use Criteria.addEqualByColumn

I have an m:n relationship between two tables/classes
A and B, modeled with an A_TO_B intermediate table
in-between.

I'd like to get all the instances of B associated with
a given A as a Collection.  The SQL might look like:

SELECT * FROM B
WHERE 
B.B_ID = A_TO_B.B_ID AND
A_TO_B.A_ID = X;

where X is the value of the A.A_ID that I want.

Is Criteria.addEqualToColumn the right method, or
should I just toss in raw SQL using SQLCriteria?  How
do I get back the Collection if I use raw SQL?  Any
advice is most welcome.

Also, the list is broken on the db.apache.org Web
site.  Notes younger than 24Feb2003 don't appear. 
Thanks - MOD


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

Re: How to use Criteria.addEqualByColumn

Posted by Michael Duffy <du...@yahoo.com>.
Hi, Jakob!

I've been having some trouble navigating this.  (I
suspect it's newbie problems.)  I have m:n
relationships working fine with a single pair of
objects, but when I try to turn them on between four
sets of objects I get exceptions in my JUnit tests.

They're all working in one direction (from top to
bottom: A->B->C->D), but not bi-directionally.

Another question: I hae a foreign key relationship
between two classes where I want to pull two column
values out of a table and populate member data in a
class.  I only see one table attribute in the
<class-descriptor>.  When I want to point to foreign
key using <reference-descriptor>, it's almost as if I
HAVE to map the value I want to a class with its own
table.  

The repository.xml docs say that the table attribute
on <class-descriptor> may specify a table different
from the mapped table for the persistent class, but
it's currently not implemented. 

Do I really have to wrap a java.util.Date in a
separate class in this case, or is there another way
to do it?  Thanks - MOD


--- Jakob Braeuchi <jb...@gmx.ch> wrote:
> hi michael,
> 
> ojb handles non-decomposed m:n relationships
> internally. there's no need 
> for you to deal with the intermediate table.
> 
> jakob
> 
> Michael Duffy wrote:
> 
> >I have an m:n relationship between two
> tables/classes
> >A and B, modeled with an A_TO_B intermediate table
> >in-between.
> >
> >I'd like to get all the instances of B associated
> with
> >a given A as a Collection.  The SQL might look
> like:
> >
> >SELECT * FROM B
> >WHERE 
> >B.B_ID = A_TO_B.B_ID AND
> >A_TO_B.A_ID = X;
> >
> >where X is the value of the A.A_ID that I want.
> >
> >Is Criteria.addEqualToColumn the right method, or
> >should I just toss in raw SQL using SQLCriteria? 
> How
> >do I get back the Collection if I use raw SQL?  Any
> >advice is most welcome.
> >
> >Also, the list is broken on the db.apache.org Web
> >site.  Notes younger than 24Feb2003 don't appear. 
> >Thanks - MOD
> >
> >
> >__________________________________________________
> >Do you Yahoo!?
> >Yahoo! Platinum - Watch CBS' NCAA March Madness,
> live on your desktop!
> >http://platinum.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail:
> ojb-user-help@db.apache.org
> >
> >
> >  
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail:
> ojb-user-help@db.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

Re: How to use Criteria.addEqualByColumn

Posted by Michael Duffy <du...@yahoo.com>.
Jakob, 

I'm a bozo.  It was operator error (again).  The m:n
stuff is working fine in both directions.  I apologize
for bothering you.  Sincerely, MOD


--- Jakob Braeuchi <jb...@gmx.ch> wrote:
> hi michael,
> 
> ojb handles non-decomposed m:n relationships
> internally. there's no need 
> for you to deal with the intermediate table.
> 
> jakob
> 
> Michael Duffy wrote:
> 
> >I have an m:n relationship between two
> tables/classes
> >A and B, modeled with an A_TO_B intermediate table
> >in-between.
> >
> >I'd like to get all the instances of B associated
> with
> >a given A as a Collection.  The SQL might look
> like:
> >
> >SELECT * FROM B
> >WHERE 
> >B.B_ID = A_TO_B.B_ID AND
> >A_TO_B.A_ID = X;
> >
> >where X is the value of the A.A_ID that I want.
> >
> >Is Criteria.addEqualToColumn the right method, or
> >should I just toss in raw SQL using SQLCriteria? 
> How
> >do I get back the Collection if I use raw SQL?  Any
> >advice is most welcome.
> >
> >Also, the list is broken on the db.apache.org Web
> >site.  Notes younger than 24Feb2003 don't appear. 
> >Thanks - MOD
> >
> >
> >__________________________________________________
> >Do you Yahoo!?
> >Yahoo! Platinum - Watch CBS' NCAA March Madness,
> live on your desktop!
> >http://platinum.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail:
> ojb-user-help@db.apache.org
> >
> >
> >  
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail:
> ojb-user-help@db.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

Re: How to use Criteria.addEqualByColumn

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi michael,

ojb handles non-decomposed m:n relationships internally. there's no need 
for you to deal with the intermediate table.

jakob

Michael Duffy wrote:

>I have an m:n relationship between two tables/classes
>A and B, modeled with an A_TO_B intermediate table
>in-between.
>
>I'd like to get all the instances of B associated with
>a given A as a Collection.  The SQL might look like:
>
>SELECT * FROM B
>WHERE 
>B.B_ID = A_TO_B.B_ID AND
>A_TO_B.A_ID = X;
>
>where X is the value of the A.A_ID that I want.
>
>Is Criteria.addEqualToColumn the right method, or
>should I just toss in raw SQL using SQLCriteria?  How
>do I get back the Collection if I use raw SQL?  Any
>advice is most welcome.
>
>Also, the list is broken on the db.apache.org Web
>site.  Notes younger than 24Feb2003 don't appear. 
>Thanks - MOD
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
>http://platinum.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>