<many-to-one not-null="true" column="report_type_id" name="reportType" class="net.gbicc.csrc.console.model.ReportType"/> 建了一个many-to-one 的关系。
<hibernate-mapping> <class dynamic-update="true" table="csrc_date_limit" name="net.gbicc.csrc.console.model.DateLimit" dynamic-insert="true"> <id type="string" column="date_limit_id" length="32" name="idStr"> <generator class="uuid"/> </id> <property name="reportYear" not-null="true" length="4" type="string" column="report_year"/> <many-to-one not-null="true" column="report_type_id" name="reportType" class="net.gbicc.csrc.console.model.ReportType"/> <property name="startDateTime" not-null="true" type="calendar" column="start_datetime"/> <property name="endDateTime" not-null="true" type="calendar" column="end_datetime"/> <property name="createDateTime" not-null="true" type="calendar" column="create_datetime"/> <property name="updateDateTime" not-null="true" type="calendar" column="update_datetime"/> </class> </hibernate-mapping>
DateLimit dateLimit = new DateLimit(); dateLimit.setReportYear(reportYear); dateLimit.setReportType(new ReportType(reportTypeId)); dateLimit.setStartDateTime(DateTimeUtils .strDateTime2Calendar(startDateTime)); dateLimit.setEndDateTime(DateTimeUtils .strDateTime2Calendar(endDateTime));
dateLimitSave = dateLimitManager.save(dateLimit); //插入到数据库 后台sql语句都打出来了
System.out.pringtln(dateLimitSave.getReportType().getReportDesp());打出来是null 请问哪位高手跟我解释一下? 为什么没值。