-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: ElementCollection geting ConcurrentModificationException
PostPosted: Wed Mar 18, 2015 6:24 pm 
Newbie

Joined: Mon Jul 20, 2009 3:48 pm
Posts: 3
Hello,

I have mongodb database Collection an array of objects with another array of objects:

Code:
@Entity
public class Tournament {
    @Id
    Long id;

    @ElementCollection
    @CollectionTable
    private List<Edition>;
}

@Embeddable
public class Edition {

    @ElementCollection
    @CollectionTable
    private List<Round>
}

@Embeddable
public class Round {

    blabla;
}


When hibernate starts I get the follow error:


Code:
Caused by: java.util.ConcurrentModificationException
   at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) [rt.jar:1.8.0_31]
   at java.util.ArrayList$Itr.remove(ArrayList.java:865) [rt.jar:1.8.0_31]
   at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1698) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
   at org.hibernate.ogm.jpa.HibernateOgmPersistence.createContainerEntityManagerFactory(HibernateOgmPersistence.java:105) [hibernate-ogm-core-4.1.1.Final.jar:4.1.1.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
   at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]


Any help will be welcome =)


Top
 Profile  
 
 Post subject: Re: ElementCollection geting ConcurrentModificationException
PostPosted: Thu Mar 19, 2015 1:44 pm 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Such a mapping violates the JPA spec, an embeddable which is contained in an element collection must not contain another element collection itself.

But I think you already knew that, given that your example exactly matches the one from this SO post which discusses that mapping: http://stackoverflow.com/questions/22126397/embeddable-and-elementcollection-nesting ;)

That being said, we theoretically could support such mapping for document stores such as MongoDB where we can store everything as nested structures within one JSON document. But as this is a limitation within the ORM engine itself, I believe chances for this are rather low.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: ElementCollection geting ConcurrentModificationException
PostPosted: Fri Mar 20, 2015 4:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes I guess it's because the relational model would be really strange and involve a lot of duplications. Plus I think we could never support the bags of bags semantic as we could not differentiate duplication from one level to duplication from the other level.

If we limit our mapping to Sets, Maps or indexed Lists (@OrderColumn), then I believe it is theoretically possible. In which case, as you say Gunnar, we could make it work for document stores. We would need to improve ORM itself to detect this and offer a pluggable strategy (fail or continue). And then use a continue approach to implement it in OGM.

I think it is more practical to instead pursue the following:

1. map Edition as a plain entity and use @OnetoMany(cascade=CascadeType.ALL, orphanRemoval=true): this simulates @ElementCollection semantic
2. offer on OGM the ability to embed a (collection of) associated entity within another int he targeted structure to do one lookup for the whole structure.

Step 1. should satisfy you already for the time being.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: ElementCollection geting ConcurrentModificationException
PostPosted: Fri Mar 20, 2015 10:08 am 
Newbie

Joined: Mon Jul 20, 2009 3:48 pm
Posts: 3
Would be very good if JPA had a way to say: "Hey, it's a nosql database and the game rules will be different" =)

Emmanuel:
To map Edition as a @Entity I need to create it physically in the database, right?

To solve this problem I had to create another Collection in my database to store my sublists and we know that it makes the database lose some performance with joins and make my work a bit harder =)


Top
 Profile  
 
 Post subject: Re: ElementCollection geting ConcurrentModificationException
PostPosted: Mon Mar 23, 2015 8:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Not really harder on your side as OGM does the work for you but yes it would add a second collection.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.