[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2869) Atomic remove + add of unique properties to a persistent set fails

Pietu Pohjalainen (JIRA) noreply at atlassian.com
Fri Sep 28 04:03:57 EDT 2007


Atomic remove + add of unique properties to a persistent set fails
------------------------------------------------------------------

                 Key: HHH-2869
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2869
             Project: Hibernate3
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.5
         Environment: Hibernate 3.2.5 (2007.07.31);
Oracle 9
            Reporter: Pietu Pohjalainen
            Priority: Minor
         Attachments: hibernate-unique-showcase.zip

Trying to remove and add equal objects to a persistent set with unique property on, fails.

E.g. we have a set 'set' with one object, "X" contained in it. A sequence of
set.clear();
set.add("X");
session.update(set);

produces a unique constraint exception from the underlying database, because the update first tries to add the newly added objects, and only after that it tries to remove those.
E.g. Oracle produces the following exception: "Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SHOWCASE.SYS_C0036053) violated"

A workaround is would be to run the session.update(set); session.flush(); after clearing the set - but I would argue that interleaving the persistence-code with regular object handling code does not exactly fulfill the promise of 'transparent persistency'.

Please see the attached showcase.zip, which sets up a database. There's a 'container', which contains a set of 'values', where values should be unique across all sets in the system. When trying to remove and add the same value to a set, the program throws an exception.

The showcase driver script is located in class hibernate.Showcase. The object model classes are located in test.Container and test.Value.






-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list