Object exists. Instance with the same primary key is already in the PersistenceManager cache.
javax.jdo.JDOUserException: Object exists. Instance with the same primary key is already in the PersistenceManager cache.
at com.sun.jdori.common.CacheManagerImpl.register(Unknown Source)
at com.sun.jdori.common.PersistenceManagerImpl.register(Unknown Source)
at com.sun.jdori.common.state.StateManagerImpl.initializeSM(Unknown Source)
at com.sun.jdori.common.state.StateManagerImpl.makeAutoPersistent(Unknown Source)
at com.sun.jdori.common.state.ReachabilityHandler$AutoPersistentProcessor.process(Unknown Source)
at com.sun.jdori.common.state.ReachabilityHandler$AutoPersistentProcessor.processArray(Unknown Source)
at com.sun.jdori.common.state.ReachabilityHandler$AutoPersistentProcessor.process(Unknown Source)
at com.sun.jdori.common.state.ReachabilityHandler.process(Unknown Source)
at com.sun.jdori.common.state.StateManagerImpl.processReachability(Unknown Source)
at com.sun.jdori.common.state.StateManagerImpl.makePersistent(Unknown Source)
at com.sun.jdori.common.CacheManagerImpl.makePersistent(Unknown Source)
at com.sun.jdori.common.PersistenceManagerImpl.makePersistentInternal(Unknown Source)
at com.sun.jdori.common.PersistenceManagerImpl.makePersistent(Unknown Source)
at com.sun.jdori.common.PersistenceManagerWrapper.makePersistent(Unknown Source)
at org.cs101.fdb.impl.jdo.PersonImpl.aquireUniqueID(PersonImpl.java:114)
at org.cs101.fdb.impl.jdo.PersonImpl.store(PersonImpl.java:156)
at org.cs101.fdb.test.PersonTest.storePerson(PersonTest.java:140)
at org.cs101.fdb.test.PersonTest.testStore(PersonTest.java:150)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
from this:
// set the primary key Id number ... just an Integer, small DB, nothing special, no extents needed.
data.setId(idMgr.assignNextId());
try {
txState.getPM().evictAll();
System.out.println(txState.getPM().getObjectId(data)); // prints null
System.out.println("persistent:" +JDOHelper.isPersistent(data)); // prints false
System.out.println("transactional:" +JDOHelper.isTransactional(data)); // prints false
System.out.println("toid:" +JDOHelper.getTransactionalObjectId(data)); // prints null
txState.getPM().makePersistent(data); // causes exception
} catch (JDOUserException jdoue) {
System.out.println(jdoue);
//System.exit(1); // if I uncomment this all database tables are empty
// so there is nothing in the database to conflict.
throw new RuntimeException(jdoue);
}
This is really annoying because it doesn't say what object already exists... the failing object is not being set (I get null back when I invoke getFailedObject() on the exception. I implemented InstanceCallbacks jdoPreStore on every single persistant class I have and made them all print something unique, and apparently this error is occuring before any instance of any persistent class is stored because nothing is printed. (unless something is sneaking in without instance callbacks). Alternately, things are getting cached before I make them persistent which seems wrong. If I ignore this exception by catching it, commit gives me messages about SQL errors because PERSON_ID in my indirection table is not allowed to be null. It would seem that an instance with id=null is getting cached and then re-cached before any jdoPreStore calls are made. The null may be because the makePersistent failed though.
Anyone seen anything like this. The only thing special about this class relative to the others is that I am trying to implement a collection on it. I am implementing it as m:n relationship with an indirection table and using @ojb.collection foreignkey and remote-foreignkey xdoclet tags.
Anyone have a clue what my problem is? I'm lost...
-Gus
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
