我想知道如何使用注释@ManyToMany 创建表role_permission,同时考虑到表role_permission 中的created_at 属性。
我知道我可以做这样的事情:
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();
和
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();
有了这个,我可以避免为 role_permission 创建一个新类,但我不知道如何将 created_at 放在这个注释中。这可能吗?