-->
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: how can I create this kind of relationship?
PostPosted: Fri Sep 07, 2007 6:50 pm 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
I want to create the following relationship.
Code:
User(1)--------(n)UserBoard(n)-----(1)Board
                         |(1)
                         |                               
                         |(n)
               UserBoardField
                         |(n)
                         |
                         |(1)
                      Field


And I tried this:
Code:
@Entity
@Table(name = "user_board_fields")
public class UserBoardField implements Serializable, Comparable {
   @Embeddable
    public static class Id implements Serializable {
   private UserBoard.Id ubId;

   @Column(name = "FIELD_ID")
   private Long fieldId;

   public Id() {
   }

   public Id(UserBoard.Id ubId, Long fieldId) {
       this.ubId = ubId;
       this.fieldId = fieldId;
   }
         ......
    }

@EmbeddedId
    private Id id = new Id();

    @ManyToOne
    private UserBoard  ub;

    @ManyToOne
    @JoinColumn(name = "FIELD_ID", insertable = false, updatable = false)
    private Profilefield field;
   ......
}


The above code runs and generates the user_board_fields table. But the ids are duplicated as shown below.

Code:
USER_ID
BOARD_ID
FIELD_ID
ub_USER_ID
ub_BOARD_ID


How can I create this kind of relationship?
Thank you very much in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 10:37 am 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
I'm sure many of you know the answer. Can you please share here? Any alternative method will be appreciated too. Thank you in advance.


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.