标签:users util arraylist java cad gen tab lis table
package com.itheima.domain;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name="t_role")
public class Role {
@Id
@Column
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int rid;
@Column
private String rname;
@Column
private String rdesc;
@ManyToMany(targetEntity=User.class,cascade = CascadeType.ALL)
@JoinTable(
//声明关联表结构
name="t_user_role",
joinColumns = @JoinColumn(name = "fk_rid",referencedColumnName = "rid"),
inverseJoinColumns = @JoinColumn(name = "fk_uid",referencedColumnName = "id")
)
private List<User> users=new ArrayList<User>();
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public Role() {
}
public Role(String rname, String rdesc) {
this.rname = rname;
this.rdesc = rdesc;
}
public String getRname() {
return rname;
}
public void setRname(String rname) {
this.rname = rname;
}
public int getRid() {
return rid;
}
public void setRid(int rid) {
this.rid = rid;
}
public String getRdesc() {
return rdesc;
}
public void setRdesc(String rdesc) {
this.rdesc = rdesc;
}
}
标签:users util arraylist java cad gen tab lis table
原文地址:https://www.cnblogs.com/lei0913/p/10969711.html