I have fairly typical scenario where there is a main @Entity and everything inside him is embeddable (so everything inside doesn't make sense without the parent). Now JPA 2.0 is blocking me to nest a @ElementCollection inside a @Embeddable defined in another @ElementCollection:
JSR-317 2.6 Collections of Embeddable Classes and Basic Types 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
Now the question is: why is this? A simple example:
@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;
}
What's the problem having this? This is just an example, you could define Round and Edition as Entity and solve the problem, but in my case for a number of reasons I need to enforce that something very nested doesn't make sense without his parent.
Why JPA 2.0 has to stop me doing this?