[Teneo] Hibernate refresh failed with parent/child relationship [message #431740] |
Thu, 23 July 2009 13:22 |
koloale Messages: 41 Registered: July 2009 |
Member |
|
|
Hello!
I have the following model with parent/child relationship:
public interface ColocationGroup extends EObject {
/**
@model id="true" annotation="teneo.jpa appinfo='@Id
@GeneratedValue(strategy=SEQUENCE, generator=\"ColoGroupGen\")'"
*/
Long getId();
/**
@model opposite="parent" containment="true" annotation="teneo.jpa
appinfo='@OneToMany(fetch=EAGER)\r\n@Cascade({PERSIST, DELETE, REMOVE,
LOCK, REPLICATE, EVICT, REFRESH, DELETE_ORPHAN})'"
*/
EList<Colocation> getColocation();
}
public interface Colocation extends EObject {
/**
@model id="true"
*/
Long getId();
/**
@model opposite="colocation" transient="false" annotation="teneo.jpa
appinfo='@ManyToOne(fetch=EAGER)'"
*/
ColocationGroup getParent();
}
The following test code:
@Test
public void testRefresh() {
ColocationGroup parent =
ColocationFactory.eINSTANCE.createColocationGroup();
Colocation colo = ColocationFactory.eINSTANCE.createColocation();
parent.getColocation().add(colo);
sessionFactory.getCurrentSession().save(parent);
sessionFactory.getCurrentSession().save(colo);
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().clear();
sessionFactory.getCurrentSession().refresh(parent);
}
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractLi st.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at
org.hibernate.collection.AbstractPersistentCollection$Iterat orProxy.next(AbstractPersistentCollection.java:555)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.DefaultRefreshEventListener.onRefres h(DefaultRefreshEventListener.java:99)
at
org.hibernate.event.def.DefaultRefreshEventListener.onRefres h(DefaultRefreshEventListener.java:39)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java: 902)
at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:886)
at com.phorm.cms.model.dao.GroupDaoTest.testRefresh(GroupDaoTes t.java:97)
It seems that during cascading ColocationGroup.colocation association
'colo' entity is initialized with the new ColocationGroup object
different from 'parent' that cause removing 'colo' form
parent.getColocation() collection that eventually leads to
ConcurrentModificationException exception. Looks like a bug, is there
any way to fix it?
Thank you,
Alexey
|
|
|
Re: [Teneo] Hibernate refresh failed with parent/child relationship [message #431741 is a reply to message #431740] |
Thu, 23 July 2009 14:47 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Alexey,
Hmm, I think I need to debug this, seems like a bi-directional association relation issue.
Can you open a bugzilla with a small test model which reproduces this (and the code below)?
gr. Martin
koloale wrote:
> Hello!
> I have the following model with parent/child relationship:
>
> public interface ColocationGroup extends EObject {
> /**
> @model id="true" annotation="teneo.jpa appinfo='@Id
> @GeneratedValue(strategy=SEQUENCE, generator=\"ColoGroupGen\")'"
> */
> Long getId();
>
> /**
> @model opposite="parent" containment="true" annotation="teneo.jpa
> appinfo='@OneToMany(fetch=EAGER)\r\n@Cascade({PERSIST, DELETE, REMOVE,
> LOCK, REPLICATE, EVICT, REFRESH, DELETE_ORPHAN})'"
> */
> EList<Colocation> getColocation();
>
> }
>
> public interface Colocation extends EObject {
> /**
> @model id="true"
> */
> Long getId();
>
> /**
> @model opposite="colocation" transient="false" annotation="teneo.jpa
> appinfo='@ManyToOne(fetch=EAGER)'"
> */
> ColocationGroup getParent();
> }
>
> The following test code:
>
> @Test
> public void testRefresh() {
> ColocationGroup parent =
> ColocationFactory.eINSTANCE.createColocationGroup();
>
> Colocation colo = ColocationFactory.eINSTANCE.createColocation();
> parent.getColocation().add(colo);
> sessionFactory.getCurrentSession().save(parent);
> sessionFactory.getCurrentSession().save(colo);
> sessionFactory.getCurrentSession().flush();
> sessionFactory.getCurrentSession().clear();
>
> sessionFactory.getCurrentSession().refresh(parent);
> }
>
> java.util.ConcurrentModificationException
> at
> java.util.AbstractList$Itr.checkForComodification(AbstractLi st.java:372)
> at java.util.AbstractList$Itr.next(AbstractList.java:343)
> at
> org.hibernate.collection.AbstractPersistentCollection$Iterat orProxy.next(AbstractPersistentCollection.java:555)
>
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.DefaultRefreshEventListener.onRefres h(DefaultRefreshEventListener.java:99)
>
> at
> org.hibernate.event.def.DefaultRefreshEventListener.onRefres h(DefaultRefreshEventListener.java:39)
>
> at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java: 902)
> at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:886)
> at
> com.phorm.cms.model.dao.GroupDaoTest.testRefresh(GroupDaoTes t.java:97)
>
> It seems that during cascading ColocationGroup.colocation association
> 'colo' entity is initialized with the new ColocationGroup object
> different from 'parent' that cause removing 'colo' form
> parent.getColocation() collection that eventually leads to
> ConcurrentModificationException exception. Looks like a bug, is there
> any way to fix it?
>
> Thank you,
> Alexey
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.03568 seconds