Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA: @ElementCollection and InheritanceType.TABLE_PER_CLASS -> Duplicate column name
    text
    copied!<p>I've created the following scenario:</p> <pre><code>@javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class MyEntity implements Serializable{ @Id @GeneratedValue protected Long id; ... @ElementCollection @CollectionTable(name="ENTITY_PARAMS") @MapKeyColumn (name = "ENTITY_KEY") @Column(name = "ENTITY_VALUE") protected Map&lt;String, String&gt; parameters; ... } </code></pre> <p>As well as:</p> <pre><code>@javax.persistence.Entity public class Sensor extends MyEntity{ @Id @GeneratedValue protected Long id; ... // so here "protected Map&lt;String, String&gt; parameters;" is inherited !!!! ... } </code></pre> <p>So running this example, no tables are created and i get the following message:</p> <pre><code>WARNUNG: Got SQLException executing statement "CREATE TABLE ENTITY_PARAMS (Entity_ID BIGINT NOT NULL, ENTITY_VALUE VARCHAR(255), ENTITY_KEY VARCHAR(255), Sensor_ID BIGINT NOT NULL, ENTITY_VALUE VARCHAR(255))": com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'ENTITY_VALUE' </code></pre> <p>I also tried overriding the attributes on the Sensor class...</p> <pre><code>@AttributeOverrides({ @AttributeOverride(name = "ENTITY_KEY", column = @Column(name = "SENSOR_KEY")), @AttributeOverride(name = "ENTITY_VALUE", column = @Column(name = "SENSOR_VALUE")) }) </code></pre> <p>... but the same error.</p> <p><strong>EDIT:</strong></p> <p>Okay, I'd found out that with the Inheritance strategy "JOINED" as well as with "SINGLE_TABLE" everything works fine. Also it seems that it has nothing to do with the EclipseLink version - I tried 1.3 and 2.0.1.</p> <p><strong>END_EDIT</strong></p> <p>Can anybody help me?</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