You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Gus Heck <gu...@olin.edu> on 2004/02/17 18:39:25 UTC

Re: Problems with JDO cache

I'm really quite stuck on this. Anyone have any clues what it could be? 
Nothing I try seems to work. Everything was working just fine until I 
tried to persist a collection. Does anyone have an example of persisting 
a collection with JDO I could look at?

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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org