I've created the following scenario:
@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<String, String> parameters;
...
}
As well as:
@javax.persistence.Entity
public class Sensor extends MyEntity{
@Id
@GeneratedValue
protected Long id;
...
// so here "protected Map<String, String> parameters;" is inherited !!!!
...
}
So running this example, no tables are created and i get the following message:
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'
I also tried overriding the attributes on the Sensor class...
@AttributeOverrides({
@AttributeOverride(name = "ENTITY_KEY", column = @Column(name = "SENSOR_KEY")),
@AttributeOverride(name = "ENTITY_VALUE", column = @Column(name = "SENSOR_VALUE"))
})
... but the same error.
EDIT:
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.
END_EDIT
Can anybody help me?