I'm getting the impression noone is reading this thread but me, but for the sake of anyone who searches later, I have determined the following:

the JDORI puts objects in the cache, before calling jdoPreStore. Since o.a.o.broker.Identity reflects out the values of the Primary keys during addition to the cache, (as best I can tell by stepping through with a debugger, Identity creation is the only significant place the jdori is invoking ojb code between makePersistent and the exception) it appears that objects are getting put in with null pk values... so my attempt to fix this with Persistence call backs is doomed. That seems like a problem in the jdori, so I am going to try to work around it by taking extra measures to ensure that the Id gets assigned before makePersistent is called. I'll post if I make it work or find anything else interesting.

-Gus

Gus Heck wrote:

I found a related post from last year....

http://www.mail-archive.com/[EMAIL PROTECTED]/msg00856.html

But I don't seem to see the constructor suggested therein (single arg) anymore, or maybe I am looking in the wrong place... The only Identity I can find is o.a.o.broker.Identity but now the constructors all require the PB or this one:

new Identity(PersonBase.class, PersonBase.class, new Object[] {data.getId()});

I tried adding that in as suggested in the post like this:


private void aquireUniqueID() {
txState.beginTx();
data.setId(this.idMgr.assignNextId());
new Identity(PersonBase.class, PersonBase.class, new Object[] {data.getId()});
try {
txState.getPM().evictAll();
txState.getPM().makePersistent(data);
} catch (JDOUserException jdoue) {
System.out.println(jdoue);
throw new RuntimeException(jdoue);
}
txState.commitTx();


But I still get the same thing....

-Gus

Gus Heck wrote:

I'm getting this exception:

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]




--------------------------------------------------------------------- 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