-->
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.  [ 2 posts ] 
Author Message
 Post subject: one-to-one mapping of a fkey ref pkey in same table
PostPosted: Thu Jun 28, 2007 5:18 am 
Newbie

Joined: Thu Jun 28, 2007 2:08 am
Posts: 1
Location: Bangalore
I have two columns in a single table,
EmployeeID (Primary Key)
ManagerID (Foreign Key Ref EmployeeID)
How to create a one-to-one relational mapping of ManagerID?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 6:09 am 
Newbie

Joined: Thu Jun 21, 2007 8:01 am
Posts: 5
Hi,

there is actualy an example for this in the Hibernate documentation (and in the book, see link at top)

something like:
Code:
import javax.persistence.*;

@Entity
@Table ( name = "EMPLOYEE" )
public class Employee {

  @Id
  @GeneratedValue
  @Column(name = "EmployeeID")
  private Long employeeID;

  @ManyToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = "ManagerID")
  private Message managerID

  <snip>other attributes here<snip>
}


Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.