[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5028?page=c...
]
Jesse Hutton edited comment on HHH-5028 at 1/11/11 2:09 PM:
------------------------------------------------------------
Jesper Steen Møller: I was expecting that the child object would be removed from the
database without a rather opaque exception being thrown.
I also wasn't expecting that calling em.remove(child) would have any side affects on
parents in the current persistence context. I don't know what's going on
underneath, but I assume that some state change in the parent had to be committed after
doing nothing but call em.remove(child) which caused the cascade to happen (the PERSIST
cascade?). IIRC, this doesn't happen when CASCADE is not set.
As there is no join table in OneToMany, it makes no sense to force client code to call
parent.getFooChildren().remove(foo) and then em.remove(foo). IIRC, I tested this in
eclipse link as well, and it didn't throw an exception.
Edit: I also doubt that such a requirement (explicit removal from OneToMany collection
before child removal) is documented anywhere in the hibernate documentation, where as it
certainly is extensively with ManyToMany.
was (Author: jhutton):
Jesper Steen Møller: I was expecting that the child object would be removed from the
database without a rather opaque exception being thrown.
I also wasn't expecting that calling em.remove(child) would have any side affects on
parents in the current persistence context. I don't know what's going on
underneath, but I assume that some state change in the parent had to be committed after
doing nothing but call em.remove(child) which caused the cascade to happen (the PERSIST
cascade?). IIRC, this doesn't happen when CASCADE is not set.
As there is no join table in OneToMany, it makes no sense to force client code to call
parent.getFooChildren().remove(foo) and then em.remove(foo). IIRC, I tested this in
eclipse link as well, and it didn't throw an exception.
Calling em.remove() on child object @OneToMany relationship when
CascadeType.ALL and FetchType.EAGER are set throws exception
-----------------------------------------------------------------------------------------------------------------------------
Key: HHH-5028
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5028
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-CR-2, 3.5.1
Environment: Confirmed bug using MySQL, PostgreSQL, and Hsqldb, which is what the
test is configured with. Hibernate version is 3.5.0-CR-2 (see test app pom.xml)
Reporter: Jesse Hutton
Assignee: Gail Badner
Attachments: HibernateManyToOneEagerRemove.tar.gz
Calling em.remove(foo) on the child object of a @OneToMany relationship that is defined
with CascadeType.ALL and FetchType.EAGER throws an Exception. The cause is given as:
javax.persistence.EntityNotFoundException: deleted entity passed to persist:
And all I'm doing in the test is removing an object. See attached test case.
If, however, I remove FetchType.EAGER from the @OneToMany relationship, no exception is
thrown.
--
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