ok. but my problem is, that lots of my objects aren't stored by hand but by
the  auto-update="true" feature of collection descriptors. how can i work
around this? or would it be better to transport the new primary key back to
the client?

greetings
Juergen





Hi again,

[EMAIL PROTECTED] wrote:
> i am using client/server mode. could this cause my problem (e.g. the new
> oid isn't transported back to the client?)
>

Yes!
If you store an object in c/s that does not yet have an primary key
assigned the number is only assigned on the server!

The modified object is not transported back to the client!

The trick is to force computation of PKs before calling store.

If you call new Identity(obj) on the client the PK is computed and
written into obj.
So store won't try to assign a new PK and client and server remein
consistent.

We have written all our JUnit tests in this way to avoid failure of
testcases in c/s mode.

I have to admit that this is a nasty "feature" but don't see any simple
to implement solution to avoid this workaround.

cheers,
Thomas

>
>
>
>
>
> this is my oid mapping. i hope you mean this. in every table / object, i
> have one primary key field (oid) with parameters primarykey and
> autoincrement set true
>
>       <field-descriptor id="1"
>           name="oid"
>           column="oid"
>           jdbc-type="VARCHAR"
>           primarykey="true"
>           autoincrement="true"/>
>
>
>
>
>
>
>                     Thomas Mahler
>
>                     <thma@apache.        An:     OJB Users List
> <[EMAIL PROTECTED]>
>                     org>                 Kopie:
>
>                                          Thema:  Re: problem with newly
> created objects
>                     23.09.2002
>
>                     15:34
>
>                     Bitte
>
>                     antworten an
>
>                     "OJB Users
>
>                     List"
>
>
>
>
>
>
> OJB can only provide autoincrmeneted PK values if there is at leat one
> field declared as primary key *and* as autoincremented. Please refer to
> the tutorials for details.
>
> This is unit tested functionality !
>
> [EMAIL PROTECTED] wrote:
>
>>hi!
>>when i create a new object and store it, the object doesn't contain the
>
> new
>
>>oid after storing. this causes the problem, that after a second store,
>
> the
>
>>object will be stored again and exists with 2 different oids in the
>>database. i tried to overwrite
>>
>>private void writeObject(java.io.ObjectOutputStream out) throws
>
> IOException
>
>>in my persistent superclass and call
>>if (oid == null)
>>{
>>    new Identity(this);
>>}
>>
>>this causes serious troubles in PersistenceBrokerImpl (npe's).
>>
>>is there a default strategy to get the oid filled. shouldn't this be done
>>by ojb (i use the PersistenceBroker API, no ODMG).
>>
>>i'm using ojb 0.9.5
>>
>>
>>Juergen
>>
>>
>>--
>>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]
>
>
>
>
>



--
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