日期:2014-05-17  浏览次数:20714 次

hibernate 映射文件错误,请大牛帮帮忙怎么解决?解决之后马上给分
映射文件信息:
<?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">
<hibernate-mapping package="com.ambergic.entity">
<class name="Contact" table="tb_contact">
<id name="contactId" column="contact_id" type="java.lang.String">
<generator class="uuid" />
</id>
<property name="name" type="java.lang.String">
<column name="name" />
</property>
<property name="telephone" type="java.lang.String">
<column name="telephone" />

</property>
<many-to-one name="user" lazy="false" fetch="join"
class="com.ambergic.entity.User" cascade="none">
<column name="user_id" />
</many-to-one>

<property name="level" type="java.lang.Integer">
<column name="level" />
</property>
<property name="remark" type="java.lang.String">
<column name="remark" />
</property>

</class>
</hibernate-mapping>


错误信息:

    严重: Servlet.service() for servlet default threw exception
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.ambergic.entity.User
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:265)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:619)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3141)
hibernate?ssh??java hibernate

------解决方案--------------------
user表的问题,好好检查一下吧。