Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA: Modelling a Map<Entity, Entity>
    text
    copied!<p>I am running into an exception when generating the database tables with EclipseLink for the following model:</p> <pre><code> @Entity @Table(name="RXRACTSPOT") public class ActivitySpot implements Serializable,IsSerializable { ..... @OneToMany private Map&lt;CustomAttributeDefinition, CustomAttributeRestriction&gt; customAttributes; </code></pre> <p>--</p> <pre><code>@Entity @Table(name="RXRCUSTATTRREST") public class CustomAttributeRestriction implements Serializable </code></pre> <p>--</p> <pre><code>@Entity @Table(name="RXRCUSTATTRDEF") public class CustomAttributeDefinition implements Serializable </code></pre> <p>I encounter the following exception:</p> <blockquote> <p>Exception in thread "main" javax.persistence.PersistenceException: Exception >[EclipseLink-0] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.IntegrityException</p> </blockquote> <p>Descriptor Exceptions: </p> <blockquote> <p>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)])</p> </blockquote> <p>Runtime Exceptions: </p> <blockquote> <p>java.lang.IndexOutOfBoundsException: Index: 0, Size: 0</p> </blockquote> <pre><code>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) </code></pre> <p>Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.IntegrityException</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload