[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5046) Cannot nest collections of Embeddable and basic type on an entity
Christophe LANNOY (JIRA)
noreply at atlassian.com
Tue Mar 30 08:19:34 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36019#action_36019 ]
Christophe LANNOY commented on HHH-5046:
----------------------------------------
Mea culpa, I'm sorry, I was wrong :
I didn't understand why you changed this "issue Type" from "Bug" to "New Feature", I read again JSR-317 :
chapter 2.5 says :
"An embeddable class (including an embeddable class within another embeddable class) may contain a collection of a basic type or other embeddable class.[16]"
but chapter 2.6 says (what I didn't see) :
"An embeddable class (including an embeddable class within another embeddable class) that is contained within an element collection must not contain an element collection, nor may it contain a relationship to an entity other than a many-to-one or one-to-one relationship."
JSR-317 do not allow what I wan't to do.
Yes, such a feature would be usefull in hibernate (I tried with Hibernate annotation too) and in the next jpa spec. Actually, in entity-manager implementation, a good feature would be a more clear error message that said it is not possible to do nesting (java.util.ConcurrentModificationException on start is not very helpfull).
We have found a workaround : making, in my example, EmbElement as Entity and cascading all / orphanRemoval=true on embElements collection, in spite of in our application the class is more an embeddable than an Entity.
> Cannot nest collections of Embeddable and basic type on an entity
> -----------------------------------------------------------------
>
> Key: HHH-5046
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5046
> Project: Hibernate Core
> Issue Type: New Feature
> Components: entity-manager
> Affects Versions: 3.5.0-CR-2
> Environment: Hibernate-entity-manager 3.5.0-CR-2, database H2
> Reporter: Christophe LANNOY
> Attachments: stacktrace, testEmbColl.zip
>
>
> We cannot nest a String collection on an embeddable element which is inside a collection or a map on an Entity : Entity manager do not start :
> Persistence.createEntityManagerFactory("manager1"); give us :
> Persistence.createEntityManagerFactory("manager1", configOverrides);
> ...
> Caused by: java.util.ConcurrentModificationException -> see stacktrace file attached
> Mapping is :
> @javax.persistence.Entity
> public class Entity implements Serializable {
> ...
> @ElementCollection
> private Map<String, EmbElement> embElements =new HashMap<String, EmbElement>();
> ... }
> @Embeddable
> public class EmbElement implements Serializable {
> ...
> @ElementCollection
> private Set<String> sstring = new HashSet<String>();
> ...}
> The Zip attached contains the junit class test : EmbededMapTest wich reproduce this error.
--
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