[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-5133) Refresh causes assertion failure on OneToMany (cascaded) property with new members

Ramon Casha (JIRA) noreply at atlassian.com
Tue Apr 20 02:18:22 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5133?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ramon Casha updated HHH-5133:
-----------------------------

    Attachment: TestCase1.zip

Test case (NB 6.8 or just use the src folder)

> Refresh causes assertion failure on OneToMany (cascaded) property with new members
> ----------------------------------------------------------------------------------
>
>                 Key: HHH-5133
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5133
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.1
>         Environment: Oracle 10g
>            Reporter: Ramon Casha
>         Attachments: TestCase1.zip
>
>
> An entity with a OneToMany property (cascade=all) is retrieved from the DB, then a NEW instance is added to the OneToMany property. If you call refresh on the parent it will give an assertion failure because Hibernate tries to refresh the added object although it is not persistent.
> eg:
> class Child { }
> class Parent {
> @OneToMany(cascade=ALL) List<Child> children;
> }
> Parent p = em.find(Parent.class, 1);
> p.children.add(new Child());
> em.refresh(p);
> This causes:
> org.hibernate.AssertionFailure: null identifier
>         at org.hibernate.engine.EntityKey.<init>(EntityKey.java:61)
>         at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:102)
>         at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:1117)
>         at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1100)
>         at org.hibernate.engine.CascadingAction$3.cascade(CascadingAction.java:203)
>         at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:392)
>         at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:335)
>         at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
>         at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:425)
>         at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:362)
>         at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:338)
>         at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
>         at org.hibernate.engine.Cascade.cascade(Cascade.java:161)
>         at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:127)
>         at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:62)
>         at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:1108)
>         at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1088)
>         at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:734)
>         at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:709)

-- 
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