[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6697) EntityManager.persist should through EntityExistsException instead of PersistenceException
Michael Rudolf (JIRA)
noreply at atlassian.com
Thu Sep 29 15:02:33 EDT 2011
EntityManager.persist should through EntityExistsException instead of PersistenceException
------------------------------------------------------------------------------------------
Key: HHH-6697
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6697
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.7
Environment: Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.5.0_22
Java home: C:\Program Files\Java\jdk1.5.0_22\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
Reporter: Michael Rudolf
The persist method of the {{EntityManager}} interface is not implemented according to the specification. If handed an already existing entity, it throws an instance of {{PersistenceException}} instead of {{EntityExistsException}}. The fact that the exception's cause is an instance of {{DuplicateEntityException}} does not help clients to determine the reason for the failure in a vendor-independent fashion. Changing this behavior will most likely not break existing clients, because they often catch instances of {{PersistenceException}}, which will also catch {{EntityExistsException}} instances. However, it will enable clients to detect the reason for the failure and thereby allow for better error reporting to the user. In fact, in case no transaction is running while this call fails, clients can also recover from the failure and queued actions can be committed afterwards.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list