[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-349?page=co...
]
Hardy Ferentschik resolved EJB-349.
-----------------------------------
Resolution: Fixed
Removed the explcit catching of the ConstraintViolationException. This means that a
ConstraintViolationException gets now wrapped around a PersistenceException. We still have
to wrap the exception since we don't want to throw any Hibernate specific exceptions
out of the entity managet. Removing the explicit catch of ConstraintViolationException
also ment that EntityExistsException will never be thrown. According to the specs it is
optional anyway.
EM Incorrectly throws EntityExistsException wrapping
ConstraintViolationException on constraint violation during delete
-----------------------------------------------------------------------------------------------------------------------
Key: EJB-349
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-349
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: Postgresql 8.2.7, Hibernate 3.2.4.GA, Hibernate EM 3.3.1.GA
Reporter: Derek Chen-Becker
Assignee: Hardy Ferentschik
Fix For: 3.4.0.CR2
When I attempt to delete an entity via a named query, and the entity has a foreign key
constraint, the EM throws an EntityExistsException that wraps the real
org.hibernate.exception.ConstraintViolationException:
INFO - Service request (GET) /org/removeEmail.html took 89 Milliseconds
WARN - SQL Error: 0, SQLState: 23503
ERROR - ERROR: update or delete on table "organization_email" violates foreign
key constraint "fk_org_email" on table "organizations"
Detail: Key (id)=(1) is still referenced from table "organizations".
ERROR - EM Error
javax.persistence.EntityExistsException:
org.hibernate.exception.ConstraintViolationException: could not execute update query
at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:605)
at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:59)
I checked the source code for 3.3.1 and revision 14382 of
org.hibernate.ejb.AbstractEntityManagerImpl.java has a "FIXME" message on line
612 that basically indicates that this is a known issue. I couldn't find an existing
bug on it in JIRA, so I apologize if this is a dup. In any case, is there any way for the
EM to determine that the attempted statement was a delete and not an insert/update?
--
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