问题描述
表是many-to-one的在Action中,SchoolsFormschoolsForm=(SchoolsForm)form;SchSchoolsc=newSchSchool();我要把sc.setSchUnit(schoolsForm.getXXDM());在这里setSchUnit会出错。。因为setSchUnit的类型在的那里AbstractSchSchool这里是privateSchUnitschUnit;这种类型的,而schoolsForm.getXXDM()是String类型的,,一放下去就错了,。。高手们帮帮忙555映射文件也发出来看看吧<hibernate-mapping><classname="hibernates.SchSchool"table="SCH_SCHOOL"schema="dbo"catalog="schools"><idname="schId"type="java.lang.String"><columnname="SCH_ID"length="32"/><generatorclass="assigned"/></id><many-to-onename="dmYxsbb"class="hibernates.DmYxsbb"fetch="select"><columnname="YXSBBM"length="1"/></many-to-one><many-to-onename="schUnit"class="hibernates.SchUnit"fetch="select">就是这里了。<columnname="XXDM"length="5"/></many-to-one><many-to-onename="dmYxslb"class="hibernates.DmYxslb"fetch="select"><columnname="YXSLBM"length="1"/></many-to-one><propertyname="schName"type="java.lang.String"><columnname="SCH_NAME"length="60"not-null="true"/></property><propertyname="yxsywmc"type="java.lang.String"><columnname="YXSYWMC"length="180"/></property><propertyname="yxsjc"type="java.lang.String"><columnname="YXSJC"length="20"/></property><propertyname="jlny"type="java.lang.String"><columnname="JLNY"length="6"/></property><propertyname="xzfzr"type="java.lang.String"><columnname="XZFZR"length="30"/></property><propertyname="dwfzr"type="java.lang.String"><columnname="DWFZR"length="30"/></property><setname="schClasses"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.SchClass"/></set><setname="eduClassSets"inverse="true"><key><columnname="SCH_ID"length="32"/></key><one-to-manyclass="hibernates.EduClassSet"/></set><setname="tchTeachers"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.TchTeacher"/></set><setname="pubSchTerms"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.PubSchTerm"/></set><setname="stuStudents"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.StuStudent"/></set><setname="schZxsjs"inverse="true"><key><columnname="SCH_ID"length="32"/></key><one-to-manyclass="hibernates.SchZxsj"/></set><setname="schZies"inverse="true"><key><columnname="SCH_ID"length="32"/></key><one-to-manyclass="hibernates.SchZy"/></set><setname="schSubjectTeams"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.SchSubjectTeam"/></set><setname="sysSchRoles"inverse="true"><key><columnname="SCH_ID"length="32"not-null="true"/></key><one-to-manyclass="hibernates.SysSchRole"/></set></class></hibernate-mapping>
解决方案
解决方案二:
1.你到你的DTO类中看看,每个对应的属性是什么类型的。2.不要浪费时间,直接重新生存DTO/DAO/IAO.记住要先加Spring.