A bit of digging through the documentation and I've found I can configure the sequence manager to get OJB using the db's autoincrement functionality, so that's the next thing to try.
I can't believe I've been banging my head against the wall for over a week just because my repository descriptors were missing autoincrement="true" fields :-(
L.
Armin Waibel wrote:
Hi Laurie,
I will try to do my best to shed some light on this.
First do remove all access="anonymous" setting from your descriptors (expect those for 1:1 relations) to eliminate side-effects of this setting.
> First, the insertion of player1 fails, as it should. But I expected it > to fail on the call to lock(). It doesn't fail until the commit() at > which point I get a org.apache.ojb.odmg.TransactionAbortedExceptionOJB. > Is this the expected behaviour? >
This is normal behaviour. If you lock an existing object nothing should happend. OJB does not perform any sql-queries when you lock an object. When tx.commit() was called OJB performs the sql-queries.
In your example you do
> p1 = new Player("name1", "player11", "pwd");
and say that this object already exist. Why? This object only exist if the same PK exist in DB already. The defined PK field is ID and you don't set this field in p1. So OJB assume this is a new object and try to insert it.
I don't know how the anonymous PK field was handled, AFAIK we don't have tests for that use case. As I said above try without this attribute for PK field. You can set ID as private field without get/set methods in Player (if you using PersistentFieldDirectAccessImpl as PersistentFieldClass property in OJB.properties - this is default setting).
regards, Armin
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]