hi peter,

setting an associated object works fine for me:

Query query;
Criteria crit;
Person person;
Person partner;

crit = new Criteria();
crit.addEqualTo("id", new Integer(4));
query = new QueryByCriteria(Person.class, crit);
person = (Person) broker.getObjectByQuery(query);

crit = new Criteria();
crit.addEqualTo("id", new Integer(5));
query = new QueryByCriteria(Person.class, crit);
partner = (Person) broker.getObjectByQuery(query);

person.setPartner(partner);     <<< person 5 is partner of person 4
person.setGeburtsDatum(new Date());
broker.store(person);

these are some of  the generated sqls :

SELECT
A0.isBoss,A0.gebDat,A0.idTest,A0.entryDate,A0.adresse,A0.idPartner,A0.name,A
0.test,A0.vorname,A0.id FROM tabPerson A0 WHERE A0.id = '4'

SELECT
A0.isBoss,A0.gebDat,A0.idTest,A0.entryDate,A0.adresse,A0.idPartner,A0.name,A
0.test,A0.vorname,A0.id FROM tabPerson A0 WHERE A0.id = '5'

UPDATE tabPerson SET vorname='M.', name='Z.', adresse='',
gebDat='2002-11-22', test='2', isBoss='true', entryDate='2002-11-22
14:19:19.718', idPartner='5', idTest='' WHERE id = '4' AND entryDate =
'2002-11-22 14:18:02.0'

btw: i use the latest from cvs, maybe you should try this as well...

hth
jakob

----- Original Message -----
From: "Peter Rajsky" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 9:08 PM
Subject: RE: 0..1 associations & dynamic proxies


> Thanks Jakob,
>
> I mapped it as 'Integer' and not 'int' and it is working now.
>
> The issue, which is still not working, is that when
> I load object using
> broker.getCollectionByQuery(...) and then I set the
> associated object (in your case partner),
> then the association to partner is not stored
> to database correctly.
>
> If I loaded the object using broker.getObjectByIdentity
> method, it is working.
>
> Don't you know how to solve this?
>
> Thanks a lot.
>
> -----Puvodní zpráva-----
> Od: Jakob Braeuchi [mailto:[EMAIL PROTECTED]]
> Odesláno: 22. novembra 2002 2:08
> Komu: OJB Users List
> Predmet: Re: 0..1 associations & dynamic proxies
>
>
> hi peter,
>
> yes i have a simple testcase :
>
> person having a partner both of class Person implementing IPerson
>
> public class Person implements IPerson
> {
> ...
> private Integer idPartner;
> private IPerson partner;
> ...
> }
>
> public interface IPerson
> {
> ...
> public IPerson getPartner();
> ...
> }
>
> if a person has no partner there is no prxy for it, getPartner() returns
> null.
>
> the repository is straight forward:
>
> ....
>       />
>        <field-descriptor id="9"
>          name="idPartner"
>          column="idPartner"
>          jdbc-type="INTEGER"
>       />
>
>       <reference-descriptor
>          name="partner"
>          class-ref="brj.ojb.Person"
>          proxy="true"
>       >
>          <foreignkey field-id-ref="9"/>
>       </reference-descriptor>
> ...
>
> hth
> jakob
>
> ----- Original Message -----
> From: "Peter Rajsky" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, November 22, 2002 6:06 PM
> Subject: 0..1 associations & dynamic proxies
>
>
> > hello,
> > does anybody have 1 to 0..1 associations and uses
> > dynamic proxies? what is your experience with it?
> > how do you deal with dynamic proxies when the real
> > object is null?
> >
> > thanks, pr
> >
> > --
> > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>


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

Reply via email to