Duplicate column name by JPA with @ElementCollection and @Inheritance
- by gerry
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.
Can anybody help me?