User 表:
@ManyToMany(cascade = { CascadeType.MERGE }) @JsonIgnore @JoinTable(name = "UserRole", joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "id") }) private Collection<Role> roles;
Role表:
@ManyToMany(mappedBy = "roles") @Basic(fetch = FetchType.EAGER) private Collection<User> users;