I am running into an exception when generating the database tables with EclipseLink for the following model:
@Entity
@Table(name="RXRACTSPOT")
public class ActivitySpot implements Serializable,IsSerializable {
.....
@OneToMany
private Map<CustomAttributeDefinition, CustomAttributeRestriction> customAttributes;
--
@Entity
@Table(name="RXRCUSTATTRREST")
public class CustomAttributeRestriction implements Serializable
--
@Entity
@Table(name="RXRCUSTATTRDEF")
public class CustomAttributeDefinition implements Serializable
I encounter the following exception:
Exception in thread "main" javax.persistence.PersistenceException: Exception >[EclipseLink-0] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions:
Exception [EclipseLink-93] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [RXRCUSTATTRREST] is not present in this descriptor. Descriptor: RelationalDescriptor(com.rubiconred.activitystream.core.model.ActivitySpot --> [DatabaseTable(RXRACTSPOT)])
Runtime Exceptions:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:417)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:164)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:221)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:209)
at com.rubiconred.activitystream.database.ActivityStreamDatabaseUtils.dropAndCreateTables(ActivityStreamDatabaseUtils.java:64)
at com.rubiconred.soauiext.server.db.CreateOneSpotDatabases.main(CreateOneSpotDatabases.java:16)
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.IntegrityException
If I remove the Map in RXRACTSPOT then the tables RXRCUSTATTREST and RXRCUSTATTRDEF are successfully created. With the Map neither table is created and the exception is thrown. I suspect I am missing some annotation on the Map but I have been unable to find an example for a Map with both key and value as Entities.