many to many relation with attributes using annotations
annotations, hibernate, jpa, many-to-many
Solution
I gave up and I used the intermediary. I just followed this tutorial and it works pretty well.
http://www.mkyong.com/hibernate/hibernate-many-to-many-example-join-table-extra-column-annotation/
Problem
I want to know how to create the table role_permission with the annotation @ManyToMany taking into account the attribute created_at in the table role_permission. I know that I can do something like this: ``` public class Role implements Serializable{ @Id @Column(name = "_id") private String id; @Column(name = "name") @NotNull private String name; @Column(name = "description") private String description; @ManyToMany(cascade = {CascadeType.ALL}) @JoinTable(name="role_permission", schema=joinColumns={@JoinColumn(name="idRole")}, inverseJoinColumns={@JoinColumn(name="idPermission")}) private Set<Permission> permissions=new HashSet(); ``` And ``` public class Permission implements Serializable{ @Id @Column(name = "_id") private String id; @Column(name = "name") @NotNull private String name; @Column(name = "description") private String description; @ManyToMany(cascade = {CascadeType.ALL}) @JoinTable(name="role_permission", schema=joinColumns={@JoinColumn(name="idPermission")}, inverseJoinColumns={@JoinColumn(name="idRole")}) private Set<Permission> roles=new HashSet(); ``` With this I can avoid to create a new class for role_permission, but I dont know how to put created_at in this annotation. Is this possible?