/*
CREATE TABLE myentity(
id primary key
);
CREATE TABLE list_entity(
id primary key
)
CREATE TABLE relation_table(
myentityid references myentity(id),
listentityid references listentity(id)
);
*/
class MyEntity{
private Integer id;
//...
@ManyToMany
@JoinTable(
name="relation_table",
joinColumns=@JoinColumn(name="myentityid", referencedColumnName="id"),
inverseJoinColumns=@JoinColumn(name="listentityid", referencedColumnName="id"))
private List<ListEntity> myListRelation;
//...
}
class ListEntity{
private Integer id;
//...
@ManyToMany(mappedBy="myListRelation", fetch = FetchType.LAZY)
private List<MyEntity> myEntities;
//...
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.