I am using Hibernate version 3.3.2.GA with annotations.
I have inheritance between two classes, the first one:
@Entity
@Table(name = "SUPER_CLASS")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="DISCR_TYPE",
discriminatorType= DiscriminatorType.STRING
)
@org.hibernate.annotations.Entity(mutable = false)
public class SuperClass { }
The subclass maps to an additional table:
@Entity
@DiscriminatorValue("VALUE")
@org.hibernate.annotations.Entity(mutable = false)
@SecondaryTable(name = "V_SECONDARY_TABLE",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID"))
public class SubClass extends SuperClass {
@Embedded
public Field getField() {
return getField;
}
}
If the field consists of two different fields
@Embeddable
public class Field {
@Column("FIELD_1") String field1
@Column("FIELD_2") String field2
}
Now, when I create a request for SubClass, the fields FIELD_1 and FIELD_2 are looked up on SuperClass, even if they are defined in a subclass.
I cannot set the table in the @Column annotation to a field, because the Field class that he reused somewhere. I need to specify it in the SubClass class.
How to indicate that a field should be searched in the secondary table?
Also at the Hibernate Forum
source
share