Hibernate中Entity实体类的写法

记录下一个Entity类的写法,方便以后查阅:

 package com.bupt.auth.entity;

 import java.util.Date;

 import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table; @Entity
@Table(name="token")
public class Token {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id", unique=true, nullable=false)
private Long id; @Column(name="info")
private String info; @Column(name="starttime")
private Date starttime; @Column(name="endtime")
private Date endtime; @ManyToOne(targetEntity=User.class)
@JoinTable(name="userToken",
joinColumns=@JoinColumn(name="token_id",referencedColumnName="id",unique=true),
inverseJoinColumns=@JoinColumn(name="user_id",referencedColumnName="id"))
private User user; public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public Date getStarttime() {
return starttime;
}
public void setStarttime(Date starttime) {
this.starttime = starttime;
}
public Date getEndtime() {
return endtime;
}
public void setEndtime(Date endtime) {
this.endtime = endtime;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
} }
上一篇:【JSP中引入文件】JSP中获取根路径+引用js文件


下一篇:SRS流媒体服务器搭建+ffmpeg推流VLC取流观看