You're running into a collision between java's concept of object
identity and Hibernate's concept of object identity.
Two java objects are equal if they share the same memory address.
Two hibernate objects are equal if they have the same id.
So, if you do:
Session A = getSession();
Session B = getSession();
Object obA = A.load(foo.class, "id");
A.evict(obA);
Object obB = B.load(foo.class, "id");
obA and obB now both reference the same *database* object, but are
distinct *java* objects.
Now when you try to do:
B.lock(obA, LockMode.NONE);
You'll throw an error because session B already *has* the same
database object (obB) in memory and hence can't lock obA.
--- Pat
> -----Original Message-----
> From: Scott F. Walter [mailto:[EMAIL PROTECTED]
> Sent: Sunday, May 29, 2005 10:37 PM
> To: Tapestry users
> Subject: Weird Tapestry/Spring/Hibernate Problem
>
> For the record I am using Hibernate/Tapestry/Spring with the Spring
> OpenViewInSession Filter.
>
> I have an object that is stored in my Visit object that contains a lazy
> collection. On a page inside the pageBeginRenderer, I attempt to access
> the lazy collection and I get the standard "Failed to lazily initialize
> a collection - no session or session was closed" exception. So right
> before the code I access the collection I attempt to reattach the object
> in the Visit with the Hibernate lock method. This time I get the
> exception "NonUniqueObjectException: a different object with the same
> identifier value was already associated with the session
>
> I am in a catch 22. First Hibernate tells me I'm not in a session, but
> when I try to bring the object into the session it tells me that I'm
> already in the session?
>
> Any clues or suggesions.
>
>
>
> Scott F. Walter Scott F. Walter
> Principal Consultant
> Vivare, Inc.
>
> E: [EMAIL PROTECTED]
> E: [EMAIL PROTECTED]
> Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
>
>
>
>
> ---------------------------------------------------------------------
> 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]