Turns out that for the table in question, I have a foreign key reference setup and the value for the field-ref-id was set to the id of the primary key and not to the field that is the foreign-key. As a result, every time I tried an update, the primary key got set to null since, I suppose, I didn't have an active reference to the "foreign" object.

I suppose there are situations where you might want your table's primary key to also be a foreign key, but I'm not sure what they would be. Maybe there should be a sanity check on the repository.xml, beyond just syntax?

hi,

check that the primary key is not set to null in the object that you are going to 
store.
If the primary key is of numeric type, also check that the value is not 0 (not 
primitive 0 nor Number.longValue() == 0), or it will be interpreted as null causing an 
insert instead of an update.

hope to be of any help
danilo

I'm having a problem with updates. I haven't had this problem in the past with OJB, and thought I'd throw out a question before I start stepping through the code. I've been using OJB for the last 18 months and don't remember seeing this problem.

I query OJB to get my object to update, using the primary key. I update the object, then call broker.store to update the object. However, the object, which is defined in th repository with "autoincrement=true" for the primary key, is INSERTed and NOT updated. I've tried this with HSQLDB and ORACLE. It's happening with both.

I'm using release candidate 4 of OJB.

Any hints are greatly appreciated.

Oh, and I've tried explicitly telling OJB to do an update not an insert.



-- Charles E Brault [EMAIL PROTECTED] "Where are we going, and why am I in this handbasket?"


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



Reply via email to