本文主要是介绍1.复合主键:Object,hbm,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
package com.bjpowernode.hibernate;import java.util.Date;/*** 核算期间* @author wangy**/
public class FiscalYearPeriod {private FiscalYearPeriodPK fiscalYearPeriodPK;//开始日期private Date beginDate;//结束日期private Date endDate;//状态private String periodSts;public Date getBeginDate() {return beginDate;}public void setBeginDate(Date beginDate) {this.beginDate = beginDate;}public Date getEndDate() {return endDate;}public void setEndDate(Date endDate) {this.endDate = endDate;}public String getPeriodSts() {return periodSts;}public void setPeriodSts(String periodSts) {this.periodSts = periodSts;}public FiscalYearPeriodPK getFiscalYearPeriodPK() {return fiscalYearPeriodPK;}public void setFiscalYearPeriodPK(FiscalYearPeriodPK fiscalYearPeriodPK) {this.fiscalYearPeriodPK = fiscalYearPeriodPK;}
}
package com.bjpowernode.hibernate;import java.io.Serializable;public class FiscalYearPeriodPK implements Serializable {//核算年private int fiscalYear;//核算月private int fiscalPeriod;public int getFiscalYear() {return fiscalYear;}public void setFiscalYear(int fiscalYear) {this.fiscalYear = fiscalYear;}public int getFiscalPeriod() {return fiscalPeriod;}public void setFiscalPeriod(int fiscalPeriod) {this.fiscalPeriod = fiscalPeriod;}@Overridepublic int hashCode() {final int prime = 31;int result = 1;result = prime * result + fiscalPeriod;result = prime * result + fiscalYear;return result;}@Overridepublic boolean equals(Object obj) {if (this == obj)return true;if (obj == null)return false;if (getClass() != obj.getClass())return false;final FiscalYearPeriodPK other = (FiscalYearPeriodPK) obj;if (fiscalPeriod != other.fiscalPeriod)return false;if (fiscalYear != other.fiscalYear)return false;return true;}}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping><class name="com.bjpowernode.hibernate.FiscalYearPeriod" table="t_fiscal_year_period"><composite-id name="fiscalYearPeriodPK"><key-property name="fiscalYear"/><key-property name="fiscalPeriod"/></composite-id><property name="beginDate" type="date"/><property name="endDate" type="date"/><property name="periodSts"/></class>
</hibernate-mapping>
这篇关于1.复合主键:Object,hbm的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!