报错:Hibernate: insert into epai.dbo.goods (goods_name, goods_price, goods_pic, goods_desc, saler_id, begin_time, end_time, buyer_id, goods_status) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
2009-5-20 22:10:34 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
org.hibernate.TransientObjectException: com.yourcompany.struts.entity.User
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.yourcompany.struts.dao.hibimpl.BaseHibernateDAO.add(BaseHibernateDAO.java:27)
at com.yourcompany.struts.dao.hibimpl.GoodsDAOHibimpl.add(GoodsDAOHibimpl.java:13)
at com.yourcompany.struts.biz.impl.GoodsBizImpl.addGoods(GoodsBizImpl.java:21)
at com.yourcompany.struts.action.GoodsAction.doAdd(GoodsAction.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
相关配置文件:
<?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 - Hibernate Tools
-->
<hibernate-mapping package="com.yourcompany.struts.entity">
<class name="Goods" table="goods" schema="dbo" catalog="epai">
<id name="goodsId" type="java.lang.Long">
<column name="goods_id" />
<generator class="native" />
</id>
<property name="goodsName" type="java.lang.String">
<column name="goods_name" length="50" not-null="true" />
</property>
<property name="goodsPrice" type="java.lang.Double">
<column name="goods_price" scale="4" not-null="true" />
</property>
<property name="goodsPic" type="java.lang.String">
<column name="goods_pic" length="500" />
</property>
<property name="goodsDesc" type="java.lang.String">
<column name="goods_desc" length="3000" />
</property>
<many-to-one name="saler" class="User">
<column name="saler_id" not-null="true"></column>
</many-to-one>
<property name="beginTime" type="java.sql.Date" >
<column name="begin_time" length="23" />
</property>
<property name="endTime" type="java.sql.Date">
<column name="end_time" length="23" />
</property>
<many-to-one name="buyer" class="User">
<column name="buyer_id"></column>
</many-to-one>
<property name="goodsStatus" type="java.lang.Integer">
<column name="goods_status" not-null="false" />
</property>
<set name="bids" inverse="true" lazy="false">
<key>
<column name="goods_id" not-null="true" />
</key>
<one-to-many class="Bid" />
</set>
</class>
</hibernate-mapping>
望高手帮忙解决下,多谢