Hibernate 在 JoinTable (List<>) 中声明复合主键
如何使用 HQL(Hibernate 查询语言)在边表中声明复合主键?以前我在课堂上声明了一个可连接的,一切正常,它创建了两列的复合主键。这是我使用的代码:
之前(工作)
@Id
@SequenceGenerator(name="someSequence", sequenceName="SEQ_APP", allocationSize =1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="appSequence")
@Column(name="id")
private int setting_id;
@OneToOne
private User user;
@ManyToMany
@JoinTable(
name="tbl_settings_objectproxy",
joinColumns = @JoinColumn(name = "id"),
inverseJoinColumns = @JoinColumn( name = "objectproxy_id")
)
private Set<SomeObject> objectproxy;
现在我整理了所有内容,将 Set 更改为 List 并添加了另一个边桌。现在hibernate按照它应该做的那样创建两个边表,但它没有声明任何主键......有人知道如何解决这个问题吗?这是我的新代码:
之后(它不再创建复合主键,它甚至没有声明任何主键)
@Id
@SequenceGenerator(name="someSequence", sequenceName="SEQ_APP", allocationSize =1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="appSequence")
@Column(name="id")
private int setting_id;
@OneToOne
private User user;
@ManyToMany
@JoinTable(
name="tbl_settings_objectproxy",
joinColumns = @JoinColumn(name = "id"),
inverseJoinColumns = @JoinColumn( name = "objectproxy_id")
)
private List<SomeObject> objectProxyForSomething;