- packagecom.SAFAS.mobilecatch.server.hibernate.model;
- /**
- *V4cDiseasespreventionentity.
- *
- *@authorMyEclipsePersistenceTools
- */
- publicclassV4cDiseasespreventionimplementsjava.io.Serializable{
- //Fields
- privateV4cDiseasespreventionIdid;
- //Constructors
- /**defaultconstructor*/
- publicV4cDiseasesprevention(){
- }
- /**fullconstructor*/
- publicV4cDiseasesprevention(V4cDiseasespreventionIdid){
- this.id=id;
- }
- //Propertyaccessors
- publicV4cDiseasespreventionIdgetId(){
- returnthis.id;
- }
- publicvoidsetId(V4cDiseasespreventionIdid){
- this.id=id;
- }
- }
V4cDiseasespreventionId
- packagecom.SAFAS.mobilecatch.server.hibernate.model;
- /**
- *V4cDiseasespreventionIdentity.
- *
- *@authorMyEclipsePersistenceTools
- */
- publicclassV4cDiseasespreventionIdimplementsjava.io.Serializable{
- //Fields
- privateIntegerproduceClassify4id;
- privateStringproduceClassify4name;
- privateShortqualityStandardId;
- privateShortenvironmentStandardId;
- privateShortproducingRuleId;
- privateShortproduceSampleStandardId;
- privateStringproducingRuleCode;
- privateStringproducingRuleName;
- privateStringremark;
- privateStringpesticideName;
- privateStringpreventionMethod;
- //Constructors
- /**defaultconstructor*/
- publicV4cDiseasespreventionId(){
- }
- /**minimalconstructor*/
- publicV4cDiseasespreventionId(IntegerproduceClassify4id){
- this.produceClassify4id=produceClassify4id;
- }
- /**fullconstructor*/
- publicV4cDiseasespreventionId(IntegerproduceClassify4id,
- StringproduceClassify4name,ShortqualityStandardId,
- ShortenvironmentStandardId,ShortproducingRuleId,
- ShortproduceSampleStandardId,StringproducingRuleCode,
- StringproducingRuleName,Stringremark,StringpesticideName,
- StringpreventionMethod){
- this.produceClassify4id=produceClassify4id;
- this.produceClassify4name=produceClassify4name;
- this.qualityStandardId=qualityStandardId;
- this.environmentStandardId=environmentStandardId;
- this.producingRuleId=producingRuleId;
- this.produceSampleStandardId=produceSampleStandardId;
- this.producingRuleCode=producingRuleCode;
- this.producingRuleName=producingRuleName;
- this.remark=remark;
- this.pesticideName=pesticideName;
- this.preventionMethod=preventionMethod;
- }
- //Propertyaccessors
- publicIntegergetProduceClassify4id(){
- returnthis.produceClassify4id;
- }
- publicvoidsetProduceClassify4id(IntegerproduceClassify4id){
- this.produceClassify4id=produceClassify4id;
- }
- publicStringgetProduceClassify4name(){
- returnthis.produceClassify4name;
- }
- publicvoidsetProduceClassify4name(StringproduceClassify4name){
- this.produceClassify4name=produceClassify4name;
- }
- publicShortgetQualityStandardId(){
- returnthis.qualityStandardId;
- }
- publicvoidsetQualityStandardId(ShortqualityStandardId){
- this.qualityStandardId=qualityStandardId;
- }
- publicShortgetEnvironmentStandardId(){
- returnthis.environmentStandardId;
- }
- publicvoidsetEnvironmentStandardId(ShortenvironmentStandardId){
- this.environmentStandardId=environmentStandardId;
- }
- publicShortgetProducingRuleId(){
- returnthis.producingRuleId;
- }
- publicvoidsetProducingRuleId(ShortproducingRuleId){
- this.producingRuleId=producingRuleId;
- }
- publicShortgetProduceSampleStandardId(){
- returnthis.produceSampleStandardId;
- }
- publicvoidsetProduceSampleStandardId(ShortproduceSampleStandardId){
- this.produceSampleStandardId=produceSampleStandardId;
- }
- publicStringgetProducingRuleCode(){
- returnthis.producingRuleCode;
- }
- publicvoidsetProducingRuleCode(StringproducingRuleCode){
- this.producingRuleCode=producingRuleCode;
- }
- publicStringgetProducingRuleName(){
- returnthis.producingRuleName;
- }
- publicvoidsetProducingRuleName(StringproducingRuleName){
- this.producingRuleName=producingRuleName;
- }
- publicStringgetRemark(){
- returnthis.remark;
- }
- publicvoidsetRemark(Stringremark){
- this.remark=remark;
- }
- publicStringgetPesticideName(){
- returnthis.pesticideName;
- }
- publicvoidsetPesticideName(StringpesticideName){
- this.pesticideName=pesticideName;
- }
- publicStringgetPreventionMethod(){
- returnthis.preventionMethod;
- }
- publicvoidsetPreventionMethod(StringpreventionMethod){
- this.preventionMethod=preventionMethod;
- }
- publicbooleanequals(Objectother){
- if((this==other))
- returntrue;
- if((other==null))
- returnfalse;
- if(!(otherinstanceofV4cDiseasespreventionId))
- returnfalse;
- V4cDiseasespreventionIdcastOther=(V4cDiseasespreventionId)other;
- return((this.getProduceClassify4id()==castOther
- .getProduceClassify4id())||(this.getProduceClassify4id()!=null
- &&castOther.getProduceClassify4id()!=null&&this
- .getProduceClassify4id().equals(
- castOther.getProduceClassify4id())))
- &&((this.getProduceClassify4name()==castOther
- .getProduceClassify4name())||(this
- .getProduceClassify4name()!=null
- &&castOther.getProduceClassify4name()!=null&&this
- .getProduceClassify4name().equals(
- castOther.getProduceClassify4name())))
- &&((this.getQualityStandardId()==castOther
- .getQualityStandardId())||(this
- .getQualityStandardId()!=null
- &&castOther.getQualityStandardId()!=null&&this
- .getQualityStandardId().equals(
- castOther.getQualityStandardId())))
- &&((this.getEnvironmentStandardId()==castOther
- .getEnvironmentStandardId())||(this
- .getEnvironmentStandardId()!=null
- &&castOther.getEnvironmentStandardId()!=null&&this
- .getEnvironmentStandardId().equals(
- castOther.getEnvironmentStandardId())))
- &&((this.getProducingRuleId()==castOther
- .getProducingRuleId())||(this.getProducingRuleId()!=null
- &&castOther.getProducingRuleId()!=null&&this
- .getProducingRuleId().equals(
- castOther.getProducingRuleId())))
- &&((this.getProduceSampleStandardId()==castOther
- .getProduceSampleStandardId())||(this
- .getProduceSampleStandardId()!=null
- &&castOther.getProduceSampleStandardId()!=null&&this
- .getProduceSampleStandardId().equals(
- castOther.getProduceSampleStandardId())))
- &&((this.getProducingRuleCode()==castOther
- .getProducingRuleCode())||(this
- .getProducingRuleCode()!=null
- &&castOther.getProducingRuleCode()!=null&&this
- .getProducingRuleCode().equals(
- castOther.getProducingRuleCode())))
- &&((this.getProducingRuleName()==castOther
- .getProducingRuleName())||(this
- .getProducingRuleName()!=null
- &&castOther.getProducingRuleName()!=null&&this
- .getProducingRuleName().equals(
- castOther.getProducingRuleName())))
- &&((this.getRemark()==castOther.getRemark())||(this
- .getRemark()!=null
- &&castOther.getRemark()!=null&&this.getRemark()
- .equals(castOther.getRemark())))
- &&((this.getPesticideName()==castOther.getPesticideName())||(this
- .getPesticideName()!=null
- &&castOther.getPesticideName()!=null&&this
- .getPesticideName()
- .equals(castOther.getPesticideName())))
- &&((this.getPreventionMethod()==castOther
- .getPreventionMethod())||(this.getPreventionMethod()!=null
- &&castOther.getPreventionMethod()!=null&&this
- .getPreventionMethod().equals(
- castOther.getPreventionMethod())));
- }
- publicinthashCode(){
- intresult=17;
- result=37
- *result
- +(getProduceClassify4id()==null?0:this
- .getProduceClassify4id().hashCode());
- result=37
- *result
- +(getProduceClassify4name()==null?0:this
- .getProduceClassify4name().hashCode());
- result=37
- *result
- +(getQualityStandardId()==null?0:this
- .getQualityStandardId().hashCode());
- result=37
- *result
- +(getEnvironmentStandardId()==null?0:this
- .getEnvironmentStandardId().hashCode());
- result=37
- *result
- +(getProducingRuleId()==null?0:this.getProducingRuleId()
- .hashCode());
- result=37
- *result
- +(getProduceSampleStandardId()==null?0:this
- .getProduceSampleStandardId().hashCode());
- result=37
- *result
- +(getProducingRuleCode()==null?0:this
- .getProducingRuleCode().hashCode());
- result=37
- *result
- +(getProducingRuleName()==null?0:this
- .getProducingRuleName().hashCode());
- result=37*result
- +(getRemark()==null?0:this.getRemark().hashCode());
- result=37
- *result
- +(getPesticideName()==null?0:this.getPesticideName()
- .hashCode());
- result=37
- *result
- +(getPreventionMethod()==null?0:this
- .getPreventionMethod().hashCode());
- returnresult;
- }
- }
映射文件:
V4cDiseasesprevention.hbm.xml
- <?xmlversion="1.0"encoding="utf-8"?>
- <!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
- <!--
- MappingfileautogeneratedbyMyEclipsePersistenceTools
- -->
- <hibernate-mapping>
- <classname="com.SAFAS.mobilecatch.server.hibernate.model.V4cDiseasesprevention"table="v_4c_diseasesprevention"catalog="safas">
- <composite-idname="id"class="com.pickedpoint.SAFAS.mobilecatch.server.hibernate.model.V4cDiseasespreventionId">
- <key-propertyname="produceClassify4id"type="java.lang.Integer">
- <columnname="produceClassify_4ID"/>
- </key-property>
- <key-propertyname="produceClassify4name"type="java.lang.String">
- <columnname="produceClassify_4Name"length="20"/>
- </key-property>
- <key-propertyname="qualityStandardId"type="java.lang.Short">
- <columnname="qualityStandardID"/>
- </key-property>
- <key-propertyname="environmentStandardId"type="java.lang.Short">
- <columnname="environmentStandardID"/>
- </key-property>
- <key-propertyname="producingRuleId"type="java.lang.Short">
- <columnname="producingRuleID"/>
- </key-property>
- <key-propertyname="produceSampleStandardId"type="java.lang.Short">
- <columnname="produceSampleStandardID"/>
- </key-property>
- <key-propertyname="producingRuleCode"type="java.lang.String">
- <columnname="producingRuleCode"/>
- </key-property>
- <key-propertyname="producingRuleName"type="java.lang.String">
- <columnname="producingRuleName"length="50"/>
- </key-property>
- <key-propertyname="remark"type="java.lang.String">
- <columnname="remark"/>
- </key-property>
- <key-propertyname="pesticideName"type="java.lang.String">
- <columnname="pesticideName"length="50"/>
- </key-property>
- <key-propertyname="preventionMethod"type="java.lang.String">
- <columnname="preventionMethod"/>
- </key-property>
- </composite-id>
- </class>
- </hibernate-mapping>
hibernate 默认是联合主键,这样的话如果有一项内容为空,则整个结果就会返回会空.
解决方法:
1.删除V4cDiseasespreventionId.java;
2.将V4cDiseasesprevention.java的属性全部替换为V4cDiseasespreventionId.java的,以及它的get,set方法.
3.修改映射文件为:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.SAFAS.mobilecatch.server.hibernate.model.V4cDiseasesprevention" table="v_4c_diseasesprevention" catalog="safas">
<id name="produceClassify4id" type="java.lang.Integer">
<column name="produceClassify_4ID" />
</id>
<property name="produceClassify4name" type="java.lang.String">
<column name="produceClassify_4Name" length="20" />
</property>
<property name="qualityStandardId" type="java.lang.Short">
<column name="qualityStandardID" />
</property>
<property name="environmentStandardId" type="java.lang.Short">
<column name="environmentStandardID" />
</property>
<property name="producingRuleId" type="java.lang.Short">
<column name="producingRuleID" />
</property>
<property name="produceSampleStandardId" type="java.lang.Short">
<column name="produceSampleStandardID" />
</property>
<property name="producingRuleCode" type="java.lang.String">
<column name="producingRuleCode" />
</property>
<property name="producingRuleName" type="java.lang.String">
<column name="producingRuleName" length="50" />
</property>
<property name="remark" type="java.lang.String">
<column name="remark" />
</property>
<property name="pesticideName" type="java.lang.String">
<column name="pesticideName" length="50" />
</property>
<property name="preventionMethod" type="java.lang.String">
<column name="preventionMethod" />
</property>
</class>
</hibernate-mapping>