Hibernate declare composite primary key in JoinTable (List<>)
How do I declare the composite primary key in a side table using HQL (Hibernate query language)? Previously I got one jointable declared in my class and everything worked fine, it created a composite primary key of the two columns. This is the code I used:
BEFORE (worked)
@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;
Now I scrued everything up, I changed the Set to a List and added another side table. Now hibernate creates two side tables as it is supposed to do but it doesn't declare any primary key's... does anyone know how to fix this? This is my new code:
AFTER (it doesn't create composite primary key anymore, it doesn't even declare any primary key)
@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;