Dnia środa, 10 listopada 2004 10:02, Gerhard Grosse napisał:
> On Wed, 10 Nov 2004 01:51:59 +0100, Łukasz Korzybski <[EMAIL PROTECTED]>
>
> wrote:
> >Thanks for reply,
> >
> >Dnia środa, 10 listopada 2004 00:19, Justin Stanczak napisał:
> >> Justin Stanczak, Web Manager
> >> Vincennes University

> >
> >OK, but then why this code doesn't work as the previous one:
> >
> >            Address address = new Address();
> >            adres.setCity("Rumia1");
> >            adres.setStreet("Dunikowskiego 10");
> >
> >
> >            OQLQuery query = odmg.newOQLQuery();
> >            query.create("select osoba from " + Osoba.class.getName() +
> > "where id=1");
> >            DList res = (DList) query.execute();
> >            person = (Person) res.iterator().next();
> >
> >            person.setName("Adam");
> >            person.setAddress(adres);
> >
> >            tx.lock(person, tx.WRITE);
> >            tx.commit();
> >
> >I thought that it would store both person and address, but unless I
> > explicitly write tx.lock(address, tx.WRITE) I get a key violation:
> >
> >ERROR: SQLException during the execution of the update (for a
> > ojbtest.Person): ERROR: insert or update on table "person" violates
> > foreign key constraint "person_fk_1"
> >
> >The only difference is I retrieve person from db rather than create a new
> > one, I'm lost and haven't got ideas how to use odmg properly.
>
> You need to call tx.lock(persion, Transaction.WRITE) _before_
> modifying the persion object. Otherwise OJB will not recognize that
> the object has been modified.
>
> Gerhard
>

It doesn't help in this particular case, it seems that I have to do write lock 
on new object even when I link it as a dependent to some other persistent 
object.

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

Reply via email to