Hi all!
I have 3 classes:
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn
public class User {
@Id
private Long id;
......
}
@Entity
@SecondaryTable(name="external_user")
@Table(appliesTo="external_user",optional=false)
public class ExternalUser extends User {
@Column(table="external_user")
private String name;
......
}
@Entity
@SecondaryTable(name="external_user")
public class Guest extends ExternalUser {
@Column(table="external_user")
private String enabled;
......
}
If I insert a new Guest setting only the fields of User class the row is created in the USER and EXTERNAL_USER tables.
But when I set the "enabled" field in Gust class, i get a PK violated constraint error.
In the hibernate log a get this:
Quote:
insert into user(id) values(?)
insert into external_user(id) values(?)
insert into external_user(id,enabled) values(?,?)
Why is inserted twice in the secondary table?
I add the @Table(appliesTo="external_user",optional=false) in the Guest class and does not work.
I need this class hierarchy
Any help?
Thanks!