Thanks Armin, your reply is very helpfull.
so there is no direct solution we must call store two time , one for A
another for B.
in your opinion why is not possible to use the same philosophy of the
invers-foreignekey wich is used in 1:n ????

an other question about performance this time :

i don't know how can we do it in OJB ; when OJB prepare a statement (for
read) by default he make SELECT * FROM ... so i think if we have
a posibility to specify only fields that's we need instead of (*) we got a
good result at performance level in reading. ??? how can i do this in OJB

thx in advance.


On 2/14/06, Armin Waibel <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> ABOU LINA wrote:
> > Hi,
> >
> > i give you this sample example :
> >
> > in case  A<---->B  [1:n] :
> >      the mapping of this bidiractional navigation is guaranted by the
> use of
> > inverse-foreignkey :
> >
> >      Mapping A classe :
> >      ----------------------------------------------------
> >
> >     <collection-descriptor
> >        name="allB"
> >        element-class-ref="B"
> >     >
> >        <inverse-foreignkey field-ref="aId"/>
> >     </collection-descriptor>
> >
> >
> >     Mapping B class :
> >     ------------------------------
> >       <reference-descriptor
> >          name="a"
> >          class-ref="A"
> >       >
> >          <foreignkey field-ref="aId"/>
> >
> >       </reference-descriptor>
> >
> > so in case of  A<---->B  [1:1] i need a bidirectional navigation !!!!!
> > how to use ????
> >
>
> Do you mean how to map it?
> Declare in both classes A and B a 1:1 reference-descriptor (both class
> tables need a FK column).
>
> How to insert?
> This depends strongly on the used auto-xxx settings. If
> auto-update/delete is enabled (and PK values handled by OJB) you can do
> e.g.:
>
> broker.beginTransaction();
> // first store both objects
> broker.store(a, ObjectModification.INSERT);
> // or let OJB detect the needed operation (more overhead)
> //broker.store(a);
> broker.store(b, ObjectModification.INSERT);
> // now set references
> a.setRelatedB(b);
> b.setRelatedA(a);
> // update both
> broker.store(a, ObjectModification.UPDATE);
> broker.commitTransaction();
>
> or ()
>
> // set references first
> a.setRelatedB(b);
> b.setRelatedA(a);
> broker.beginTransaction();
> // store both objects
> broker.store(a);
> // update b to force OJB to set the FK
> // back to a (was 'null' after first store call)
> broker.store(b);
> broker.commitTransaction();
>
> or if auto-update 'link' is used
>
> broker.beginTransaction();
> // first store both objects
> broker.store(a, ObjectModification.INSERT);
> broker.store(b, ObjectModification.INSERT);
> // now set references
> a.setRelatedB(b);
> b.setRelatedA(a);
> // update both
> broker.store(a, ObjectModification.UPDATE);
> broker.store(b, ObjectModification.UPDATE);
> broker.commitTransaction();
> ...
>
> regards,
> Armin
>
>
> > my config :
> >   1. ojb 1.0.3
> >   2. i use the broker (PB-API)
> >
> >
> >
> > Thanks a lot ....
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to