Matthias,

If an object has an ID that is set (not null or zero) then ODMG considers it to be an existing, persisted object that is already in the database. So locking it for write will result in an update, not an insert. In general, you shouldn't be setting the id. If you want an existing object then retrieve it with a query. If you want to create a new instance, then create it, set the business properties, and persist it. ODMG will assign an id and perform an insert.

It's useful to at least think of your objects via a business interface that has business properties, but not any persistence related properties like the id and a timestamp. In this thinking, you can't set the id. This mindset gets you thinking more about the objects and less about the database.

Regards, Will

[EMAIL PROTECTED] wrote:
Hi,
following question about storing a new object:
I have an Object with an attribute ID of type BigDecimal.
I write the Object with ODMG: ...
tx.lock(myObject, Transaction.WRITE); tx.commit(); if I set the ID to a valid number the every thing works fine.
if I set the ID to a number witch still exists then no insert is made, but also not exception is thrown.
Is there a way to find out if the insert was successful or not?
regards Matthias Roth


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



Reply via email to