package com.blog.ytso.com.model; import java.util.Date; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; @Entity @Table(name="_teacher") public class Teacher { private int id; private String name; private String address; private Date birthday; /* * ID * 其他默认全部映射 [email protected] */ @Id public int getId() { return id; } public void setId(int id) { this.id = id; } @Basic public String getName() { return name; } public void setName(String name) { this.name = name; } /* * 如果不想让其字段映射到数据表中 可使用Transient */ @Transient public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } /* * 设置时间的类型 有DATE,TIME,TIMESTAMP */ @Temporal(TemporalType.DATE) public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/14401.html