首页>代码>spring整合hibernate+ehcache实现最简单的入门代码demo实例,对初学者很有帮助>/HibernateEHCacheExample/src/main/java/com/zuidaima/hibernate/model/Address.java
package com.zuidaima.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

@Entity
@Table(name = "ADDRESS")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY, region="employee")
public class Address {

	@Id
	@Column(name = "emp_id", unique = true, nullable = false)
	@GeneratedValue(generator = "gen")
	@GenericGenerator(name = "gen", strategy = "foreign", 
				parameters = { @Parameter(name = "property", value = "employee") })
	private long id;

	@Column(name = "address_line1")
	private String addressLine1;

	@Column(name = "zipcode")
	private String zipcode;

	@Column(name = "city")
	private String city;

	@OneToOne
	@PrimaryKeyJoinColumn
	private Employee employee;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getAddressLine1() {
		return addressLine1;
	}

	public void setAddressLine1(String addressLine1) {
		this.addressLine1 = addressLine1;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

}
最近下载更多
wycccc  LV1 2019年6月8日
ORO4444  LV12 2019年3月20日
wcy071213  LV27 2018年6月2日
ganfeng  LV2 2018年5月11日
88204879  LV2 2018年3月28日
xiaoyu888  LV5 2018年3月21日
346058210  LV6 2018年1月11日
zmqzmq  LV1 2017年3月23日
yedk123  LV1 2017年2月16日
纸天才  LV1 2017年2月15日
最近浏览更多
wordtong  LV3 2021年6月27日
mudingc木钉  LV30 2021年6月11日
hashjaaa  LV4 2021年1月7日
MARTIN66666  LV1 2020年12月26日
北巷枫  LV9 2020年12月23日
banzhenghao  LV7 2020年11月23日
fmmjjj  LV3 2020年6月26日
jimmyke  LV2 2020年6月16日
IkunLYY  LV4 2020年6月14日
jammes  LV3 2020年6月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友