[hibernate-dev] Error using the same column as DiscriminatorColumn and Id
Pablo Nussembaum
hibernate at bauna.com.ar
Thu Jan 11 17:11:20 EST 2007
Hi,
Since Hibernate 3.2 is not possible to use the same column as
discriminator and primary key. I could do it in previous versions of
hibernate.
This is the stacktrace I get:
Caused by: org.hibernate.MappingException: Repeated column in mapping
for entity: ar.com.refert.sil.bo.Child column: ident (should be mapped
with insert="false" update="false")
at
org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:647)
at
org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:690)
at
org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:445)
at
org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
Here is the code:
Parent class:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="ident",discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue("1")
public class Parent {
private Long id;
@Id
public Long getIdent() {
return id;
}
public void setIdent(Long id) {
this.id = id;
}
}
Child Class:
@Entity
@DiscriminatorValue("2")
public class Child extends Parent {
}
Thanks,
--
Pablo Nussembaum
Refert
More information about the hibernate-dev
mailing list