日期:2014-05-20 浏览次数:20810 次
<class name="com.fishingport.bean.Inportinfo" table="inportinfo" catalog="fishingport"> <id name="inportid" type="java.lang.Integer"> <column name="inportid" /> <generator class="native" /> </id> <many-to-one name="portinfo" class="com.fishingport.bean.Portinfo" fetch="select"> <column name="portid" not-null="true" /> </many-to-one> <many-to-one name="boatinfo" class="com.fishingport.bean.Boatinfo" fetch="select"> <column name="boatid" not-null="true" /> </many-to-one> <property name="inportTime" type="java.util.Date"> <column name="inportTime" length="19" not-null="true" /> </property> </class>
int num = ((Integer) this.getHibernateTemplate().find( "select count(*) from Inportinfo i where i.portinfo.portid=" + portid).iterator().next()).intValue();
list = this.getHibernateTemplate().find("from Inportinfo");
<class name="com.fishingport.bean.Inportinfo" table="inportinfo" catalog="fishingport"> <id name="inportid" type="java.lang.Integer"> <column name="inportid" /> <generator class="native" /> </id> <many-to-one name="portinfo" class="com.fishingport.bean.Portinfo" fetch="select"> <column name="portid" not-null="true" /> </many-to-one> <many-to-one name="boatinfo" class="com.fishingport.bean.Boatinfo" fetch="select"> <column name="boatid" not-null="true" /> </many-to-one> <property name="inportTime" type="java.util.Date"> <column name="inportTime" length="19" not-null="true" /> </property> </class>
------解决方案--------------------
你看一下这三张表中有没有不允许为空的字段值为空了,(数据库中没做限制)
------解决方案--------------------
你看下你的实体bean,inportTime属性是不是Date类型;
如果是,那么将XML配置成
<class name="com.fishingport.bean.Inportinfo" table="inportinfo" catalog="fishingport"> <id name="inportid" type="java.lang.Integer"> <column name="inportid" /> <generator class="native" /> </id> <many-to-one name="portinfo" class="com.fishingport.bean.Portinfo" fetch="select"> <column name="portid" not-null="true" /> </many-to-one> <many-to-one name="boatinfo" class="com.fishingport.bean.Boatinfo" fetch="select"> <column name="boatid" not-null="true" /> </many-to-one> <property name="inportTime" > </property> </class>