Hibernate Core 3.2.5.ga
Hibernate Annotation 3.3.0.ga
JDK 1.5
Hello,
I would appreciate some help on Inheritance and save()...it seems like the base instance/table Entity is not saved prior to Person...
Person per = new Person();
per.setEntityOid(1234);
session.save(per);
gives me
22:54:26,718 ERROR JDBCExceptionReporter:78 - Cannot add or update a child row: a foreign key constraint fails (`Identity/Person`, CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`entityOid`) REFERENCES `Entity` (`entityOid`) ON DELETE NO ACTION ON UPDATE NO ACTION)
22:54:26,718 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
Table Entity(entityOid);
Table Person(entityOid,firstName); // entityOid is a FK to Entity.entityOid.
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "Entity")
public class Entity implements Serializable
{
@Id
@Column(name = "entityOid", nullable = false)
protected Integer entityOid;
@Entity
@Table(name = "Entity")
public class Person
extends Entity
{
}
|