[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1716?page=c...
]
Hasan Turksoy commented on HHH-1716:
------------------------------------
As stated some related forum posts about this issue, "merge" is not setting
identifier field in case of rollback operation. I've written about this type of
solution at
here(http://www.jroller.com/comments/hasant/Weblog/hibernate_saveorupdate....
But, my project is a huge one. We've used saveOrUpdate method to save/update our
entities till now. So, our all mappings and cascades are written according to this
structure. From this point, it's very difficult to arrange and test cascades for using
with the "merge" method.
So; saveOrUpdate method should have this fix urgently.
Orphaned identities
-------------------
Key: HHH-1716
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1716
Project: Hibernate3
Issue Type: Bug
Components: core
Reporter: James Carman
When saving an object, its identity is set (for generated identities of course), even if
the transaction is rolled back. This can cause some nasty problems in webapps when using
an entity object to store data entered by the user on a form (and displaying back the data
if there are errors). Hibernate will think this object is persistent even though it's
not when using saveOrUpdate(). Is there a way that the identity values can be set back to
what they were originally (nulled out) or can you not set the identity values until
transaction completion? Here's some code:
final Foo foo = new Foo();
foo.setName( "Hello, Foo!" );
final SessionFactory sf = getSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
session.save( foo );
tx.rollback();
session.close();
session = sf.openSession();
tx = session.beginTransaction();
session.saveOrUpdate( foo );
tx.commit(); // Exception here!
session.close();
sf.close();
--
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