[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5166?page=c...
]
Alexandre FRADIN commented on HHH-5166:
---------------------------------------
Once again, sorry for my English. I was not looking for help, but trying to explain why
this is a bug...
I tried to keep my first unit test as simple as possible. May be it was too simple to
illustrate the problem.
Here a new unit test to show the difference between insert and update operations.
In the method testEvictHibernateWithUpdateOnly() :
- a user is merged
- update operations are queued
- a user is evicted
- update operations are removed from queue
- commit works fine
In the method testEvictHibernateWithInsertUpdate():
- a user is merged
- insert and update operations are queued
- a user is evicted
- insert operations are not remove from queue
- update operations are removed from queue
- commit fails
If I follow your logic, both tests should fail and not just the second one :
"Later, when the transaction was committed, Hibernate tried to flush the insert or
update, but the entities were no longer in the session, resulting in
AssertionFailure."
It is true for insert, not for update.
If evict() method remove update operations from queue, insert should be removed to.
I will figure out a way to deal with the behavior, but I think this is a severe fonctional
limitation for merge/evcit operations use with cascade="all' entities.
Where a simple evict should be cascade to the entity's associations and keep the
session clean, I will probably need to implement rollback mecanism and may be split some
business methods.
Inconsistent session state with merge/evict on
cascade="all" association
------------------------------------------------------------------------
Key: HHH-5166
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5166
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2, 3.5.1
Environment: Reproducted on :
Hibernate-core 3.3.2 and 3.5.1-Final
DB2 and HSQL DB
with annotation and classic hbm mapping
Reporter: Alexandre FRADIN
Assignee: Gail Badner
Priority: Critical
Attachments: hibernate-test-merge-evict-cascade-all.zip,
hibernate-test-update-insert.zip
My apologies for my English.
I have entities User and Role with a many-to-many association mapped with
cascade="all". So merge and evict operations on User should be applied to this
association.
When I do the following :
1) create user u existing in DB
2) add a new Role r to this user (this Role don't exists in DB)
3) merge u
4) evict the instance returned by the merge operation
5) use the same session for any operation
6) commit the session
I get this exception : "org.hibernate.AssertionFailure: possible nonthreadsafe
access to session".
There is no thread issue. I think this is a standard way to use merge and evict
operations.
I think that merge and evict operations used on modified entities leave the session in an
inconsistent state.
See unit test wich reproduct this bug.
Does a workaround exist for this bug?
Regards.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira