-->
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.  [ 3 posts ] 
Author Message
 Post subject: One to one association between two objects of same entity.
PostPosted: Thu Oct 12, 2006 2:21 pm 
Newbie

Joined: Tue Oct 10, 2006 6:42 pm
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 4:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Times Ten has a limitation, this has nothing to do with Hibernate.
I guess you can safely ignore this error

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: One to one association between two objects of same entity.
PostPosted: Tue Nov 09, 2010 9:01 am 
Newbie

Joined: Tue Nov 09, 2010 8:59 am
Posts: 1
This is an issue in both v6 and v7 of TimesTen (I believe self-referencing foreign keys are allowed in 11g).

Is there a way to get Hibernate to not generate these in hbm2ddl?


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

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.