The problem: I'm using ODMG transactions, and I normally set foreign-key ID fields directly rather than set reference-object fields. I ran into problems when I did the following sequence of events, working with an ODMG database 'db' and a PersistenceBroker 'broker':
A a = new A(); db.makePersistent(a); B b = new B(); b.setAId(a.getId()); broker.retrieveAllReferences(b); // so that B's reference to // A gets updated from the // foreign key field I just set db.makePersistent(b); In the last step, I get: java.lang.NullPointerException at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(TransactionImpl.j ava:811) at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(TransactionImpl.j ava:852) at org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:259) at org.apache.ojb.odmg.DatabaseImpl.makePersistent(DatabaseImpl.java:409) because at the time I make B persistent its reference to A is a proxy that has not yet been materialized, and cannot be materialized via getRealSubject() - it is not yet known to the persistence broker, only to the ObjectEnvelopeTable in the current transaction. My solution: I added code to TransactionImpl.assertFkAssignment() that tries to fetch the proxy via the ObjectEnvelopeTable in case real materialization fails: ... else if (ref instanceof Proxy) { IndirectionHandler ih = (IndirectionHandler) Proxy.getInvocationHandler(ref); refInstance = ih.getRealSubject(); /* Begin patch */ if (refInstance == null) { refInstance = objectEnvelopeTable.getByIdentity(ih.getIdentity()).getObject(); } /* End patch */ } ... Regards, Scott Howlett ---------------- Scott Howlett PDK Solutions Group 978-262-6692 (office) 617-721-7198 (mobile) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]