-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Inheritance, Annotation, and Save Error
PostPosted: Wed Oct 17, 2007 2:11 am 
Newbie

Joined: Mon Oct 15, 2007 8:49 pm
Posts: 7
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
{
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.