Hi Ron..
I try but the code doesn�t work..look up

My XML
<class-descriptor
 class="MyClassA"
 table="TableA">

 <field-descriptor
  id="1"
  name="id"
  column="idt_tableA"
  jdbc-type="integer"
  primarykey="true"
 />
 <field-descriptor
  id="2"
  name="desc"
  column="desc_tableA"
  jdbc-type="varchar"
  primarykey="false"
 />
 <reference-descriptor
  name="referenceToBClass"
  field-ref="id"
  class-ref="MyClassB">
  <foreignkey field-id-ref="1"/>
 </reference-descriptor>

</class-descriptor>


<class-descriptor
 class="MyClassB"
 table="TableB">

 <field-descriptor
  id="1"
  name="id"
  column="idt_tableB"
  jdbc-type="integer"
  primarykey="true"
 />
 <field-descriptor
  id="2"
  name="idCreator"
  column="id_Creator"
  jdbc-type="integer"
  primarykey="false"
 />
</class-descriptor>

In mY case I would like recover the object of MyClassA...My code below

Criteria criteria = new Criteria();
MyClassB classB = new MyClassB();
classB.setIdCreator(new Integer(2695757));
criteria.addEqualTo("referenceToBClass",classB);
Query query = new QueryByCriteria(MyclassA.class,criteria);
PersistenceBroker broker = getPersistenceBroker();
Object object = broker.getObjectByQuery(query);




----- Original Message -----
From: "Ron Gallagher" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Monday, July 28, 2003 6:11 PM
Subject: Re: Re: Query


Cesar --

The join is taken care of for you by ojb:

Criteria criteria = new Criteria()
criteria.addEqualTo("referenceToBClass","YourValueGoesHere");
Query query = new QueryByCriteria(MyClass,criteria);
PersistenceBroker broker = getPersistenceBroker();
Object object = broker.getObjectByQuery(query);

This example assumes that the class-descriptor for 'MyClass' includes a
reference-descriptor whose name is 'referenceToBClass'

Ron Gallagher
Atlanta, GA
[EMAIL PROTECTED]
>
> From: "Cesar" <[EMAIL PROTECTED]>
> Date: 2003/07/28 Mon PM 04:55:28 EDT
> To: "OJB Users List" <[EMAIL PROTECTED]>
> Subject: Re: Query
>
>     And How i use the join?( where a.idt=b.idt and)
>
> [ ]�s
> ----- Original Message -----
> From: "Leandro Rodrigo Saad Cruz" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>
> Sent: Monday, July 28, 2003 5:03 PM
> Subject: Re: Query
>
>
> Using QueryByCriteria !
>
> On Mon, 2003-07-28 at 16:51, Cesar wrote:
> > People
> > I have one query
> >
> > SQL = select a.idt, a.desc from table1 a, table2 b where a.idt=b.idt and
> > b.idUser=?
> >
> > I need execute this query to recover one object, but i can�t set the
bind
> > variable using the code below
> >
> > Query query = QueryFactory.newQuery(MyClass,Queries.SQL);
> >  PersistenceBroker broker = getPersistenceBroker();
> >  Object object = broker.getObjectByQuery(query);
> >   broker.close();
> >  return object;
> >
> > How I make to set the "bind" variable?
> >
> > [ ]�s
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> --
> Leandro Rodrigo Saad Cruz
> IT - Inter Business Tecnologia e Servicos (IB)
> http://www.ibnetwork.com.br
> http://db.apache.org/ojb
> http://xingu.sourceforge.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to