Would appreciate a clear annotation example or ref to same for the following (several hours in the docs already).
I need to perform a one to one association between two objects of the same entity type (maybe later going to one to many). I currently have the following:
@Entity
public class X implements Serializable
{
private long id;
private X child;
public X()
{
id = 0;
child = null;
}
@Id
@GeneratedValue
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
@OneToOne
public X getChild()
{
return child;
}
public void setChild(X child)
{
this.child = child;
}
}
hbmdll schema export results in my DB complaining about...
[htools] alter table X add constraint FK451CB6429033BC67 foreign key (child_id) references X;
[htools] Oct 12, 2006 1:16:15 PM org.hibernate.tool.hbm2ddl.SchemaExport create
[htools] SEVERE: Unsuccessful: alter table X add constraint FK451CB6429033BC67 foreign key (child_id) references X
[htools] Oct 12, 2006 1:16:15 PM org.hibernate.tool.hbm2ddl.SchemaExport create
[htools] SEVERE: [TimesTen][TimesTen 6.0.4 ODBC Driver][TimesTen]TT3000: self-referencing foreign keys are not allowed -- file "eeDDL.c", lineno 5784, procedure "sbEeAddFKCreate"
But my app appears able to persist such a object "chain" and read it back out of the DB.
?
Appreciate your help.
Thanks
|