As far as my understanding of JPA 2.1, section 2.6 and 11.1.14 goes, having a collection of regular Java types may optionally be annotated with @ElementCollection, in which case the collection goes to a separate table. But it isn't illegal not to have the @ElementCollection annotation set.
I got a Java EE test project here (it is built using Maven and all tests run using Arquillian, profiles are setup for GlassFish and WildFly remote): https://github.com/MartinanderssonDotcom/java-ee-concepts
This test fails in WildFly and Hibernate (work in GlassFish and EclipseLink), the archive isn't deployed: https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/master/src/test/java/com/martinandersson/javaee/jpa/mapping/elementcollection/ElementCollectionTest.java
Because this class doesn't use the @ElementCollection annotation: https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/master/src/test/java/com/martinandersson/javaee/jpa/mapping/elementcollection/Person1.java
Adding the annotation, solve the problem. Using only this class in the test would have made it to work properly: https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/master/src/test/java/com/martinandersson/javaee/jpa/mapping/elementcollection/Person2.java
|