码迷,mamicode.com
首页 > 其他好文 > 详细

jpa的常用注解

时间:2019-06-03 20:16:44      阅读:144      评论:0      收藏:0      [点我收藏+]

标签: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;
}
}

jpa的常用注解

标签:users   util   arraylist   java   cad   gen   tab   lis   table   

原文地址:https://www.cnblogs.com/lei0913/p/10969711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!