首页>代码>spring整合hibernate+ehcache实现最简单的入门代码demo实例,对初学者很有帮助>/HibernateEHCacheExample/src/main/java/com/zuidaima/hibernate/model/Employee.java
package com.zuidaima.hibernate.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToOne; import javax.persistence.Table; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Cascade; @Entity @Table(name = "EMPLOYEE") @Cache(usage=CacheConcurrencyStrategy.READ_ONLY, region="employee") public class Employee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "emp_id") private long id; @Column(name = "emp_name") private String name; @Column(name = "emp_salary") private double salary; @OneToOne(mappedBy = "employee") @Cascade(value = org.hibernate.annotations.CascadeType.ALL) private Address address; public long getId() { return id; } public void setId(long id) { this.id = id; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } }
最近下载更多