[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1716?page=c...
]
James Carman commented on HHH-1716:
-----------------------------------
For what it's worth, we decided to go with UUIDs for our ids to solve this (and other)
problems. However, it helps performance if you use a version field (with an appropriate
unsaved value) along with your UUID-based entity so that hibernate knows when an object is
new (it needs to save) vs. existing (needs to update).
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