Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

One-to-One Mapping in Hibernate  RSS feed

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to declare a One-To-One association to the same class.
Like
Person -> substiude -> Person

my mapping is:

<class name="Person">

<id name="id">
<generator class="native"/>
</id>
<property name="substituteId" unique="true"/>
<property name="name"/>

<one-to-one name="substitude" class="Person"
cascade="all" foreign-key="substituteId"/>
</class>

But no foreign key is genrated to the substitudeId.
What is my mistake?
Can someone help?

Thanks,
Srikanth.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!