I posted this to Application Architecure by mistake..
I have a piece of code that works fine on JBoss 3.2.2, but fails on Orion 2.0.2, with the following error:
Code:
Another object was associated with this id (the object with the given id was already loaded): [com.BLAH.core.entity.NextId#3]
Now I know that this is normally because there are 2 different objects loaded, both with the same id.. but the thing is, I get the item back from a collection (via Session.find() ), I never make any copies of it.. It seems that the object address is getting changed as soon as I pass the object to a Stateful Session Bean (persistence), in the following way:
Code:
PersistenceHome persistHome = PersistenceUtil.getHome();
persistence = persistHome.create();
//assign the NextId instance to the first value in a Collection
Iterator iter = nextIdCollection.iterator ();
nextId = (NextId) iter.next ();
log.info ("Next Id '" + nextId + "'");
persistence.update (nextId);
The first thing I do in the persistence.update () method is print the object passed in, and voila, it has a different address!!
Code:
Next Id 'com.kbcam.core.entity.NextId@aea8cf'
updating object: com.kbcam.core.entity.NextId@ccd249
As a result of the address changing, the update thinks it is a second (and distinct) instance of NextId, which just happens to have the same id as one already loaded into the session (which it is not).
Now while this looks like it is not specifically a Hibernate issue (but will affect Hibernate users on Orion), I'm hoping someone out there will know enough about EJB containers (in particular Orion) to be able to point me in the right direction??
My best guess so far is that this is related to Serialization somehow.
Any ideas??