Hi,
In an Entity classe I have a collection :
Code:
@ElementCollection
List<Marker> markers;
Marker is an interface:
Code:
public interface Marker {
}
The Marker interface is implemented by 2 classes:
Code:
@Embeddable
public class TextMarker implements Marker {
...
}
@Embeddable
public class MediaMarker implements Marker {
...}
When I deploy my war I get the following Hibernate error :
Code:
org.hibernate.MappingException: Could not determine type for: com.visiativ.my3dplayer.persistence.Marker, at table: Player_markers, for columns: [org.hibernate.mapping.Column(markers)]
And If I change the Marker interface to a class:
Code:
@Embeddable
public class Marker {
}
@Embeddable
public class TextMarker extends Marker {
...
}
@Embeddable
public class MediaMarker extends Marker {
...}
I get this error :
Code:
Caused by: org.hibernate.MappingException: Could not instantiate collection persister org.hibernate.persister.collection.BasicCollectionPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:242) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:201) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:430) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859) [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]
... 13 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.hibernate.persister.collection.AbstractCollectionPersister.generateSelectSizeString(AbstractCollectionPersister.java:1020) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:528) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.persister.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:77) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_20]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_20]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_20]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408) [rt.jar:1.8.0_20]
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:231) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
... 17 more
So what's the correct way to model my use case in JPA ?
Thanks