Hi Will,

if an object has an ID (not null or zero) and the
ID exists still in the Database then ODMG do nothing
(also no update as you say). I made tests with OBJ 0.9.8.

if the ID of an object is null then also ODMG do nothing.
Because I do not use autoincrement, because I have ID's of
type DECIMAL and autoincrement works only with Datatyp INTEGER.

It is ok that ODMG do nothing, but it is not ok that I get no
message over exception to notified me that something was wrong 
with my Object.

Can help some body?

regards Matthias

-----Original Message-----
From: Will Jaynes [mailto:[EMAIL PROTECTED]
Sent: Donnerstag, 20. Marz 2003 13:11
To: OJB Users List
Subject: Re: What happens when an insert with ODMG fails?


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]

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

Reply via email to