-1

我有问题:

我可以使用带有树键的 joinTable 吗,例如:

User_UserDescription_UserReg_JOIN:

User_ID   
------------
UserDescription_ID 
--------------------
UserRegistration_ID
--------------------

它看起来像这样:

User_UserDescription_UserReg_JOIN:
  |   1  |     2    |      3      |

有可能有这样的关节吗?我该怎么办,求教。

4

1 回答 1

0

一个简短的答案,因为您没有提供任何 @Entities :使用 @EmbeddedId

前任 :

@Embeddable
public class UserDescRegId {
  private Long userId;
  private Long userDescriptionId;
  private Long userRegId;
  //TODO add getters,setters, constructor, equals, hasCode...
}

@Entity
public class UserDescReg {
  private UserDescRegId id = new UserDescRegId();
  private Description description;
  private Registration reg;
  private User user;
  @EmbeddedId
  @AttributeOverrides( {
        @AttributeOverride(name = "user", column = @Column(name = "", nullable = false)),
        @AttributeOverride(name = "description", column = @Column(name = "description", nullable = false)),
        @AttributeOverride(name = "registration", column = @Column(name = "reg", nullable = false)) })
  //TODO complete @AttributeOverrive 
  public UserDescRegId getId() {
        return this.id;
    }
  //TODO getters/setters,
 }
于 2013-07-05T10:06:37.000 回答