-->
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: How to do self-join using annotations
PostPosted: Thu Jun 01, 2006 2:32 pm 
Newbie

Joined: Thu Jun 01, 2006 2:20 pm
Posts: 2
Can anyone show me how to do a self-join using Annotations?

something like:

public class Person() {
private Person friend;

public Person getFriend() {
return friend;
}

public void setFriend(Person friend) {
this.friend = friend;
}
}


Top
 Profile  
 
 Post subject: Re: How to do self-join using annotations
PostPosted: Thu May 24, 2007 7:22 am 
Newbie

Joined: Thu May 24, 2007 7:18 am
Posts: 2
Hay!!!
I am also searching for a solution to self-joins using annotations.
Any success at your end?




chunhui wrote:
Can anyone show me how to do a self-join using Annotations?

something like:

public class Person() {
private Person friend;

public Person getFriend() {
return friend;
}

public void setFriend(Person friend) {
this.friend = friend;
}
}


Top
 Profile  
 
 Post subject: Re: How to do self-join using annotations
PostPosted: Thu May 24, 2007 8:15 am 
Newbie

Joined: Wed May 23, 2007 10:35 am
Posts: 6
chunhui wrote:
Can anyone show me how to do a self-join using Annotations?

something like:

public class Person() {
private Person friend;

public Person getFriend() {
return friend;
}

public void setFriend(Person friend) {
this.friend = friend;
}
}


Code:
@Entity
public class Person() {
   @Id
   @GeneratedValue
   private Long id;
   @OneToOne
    private Person friend;

    public Person getFriend() {
        return friend;
    }

    public void setFriend(Person friend) {
        this.friend = friend;
    }


simple, isn't it?


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.