jpa的常用注解
Posted lei0913
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jpa的常用注解相关的知识,希望对你有一定的参考价值。
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的常用注解的主要内容,如果未能解决你的问题,请参考以下文章