Hibernate异常帮助:TransientObjectException [英] Hibernate Exception help: TransientObjectException
问题描述
org.hibernate.TransientObjectException:对象引用未保存的瞬态实例 - 保存瞬态实例前flushing:......
任何人都可以帮忙吗?
我正在尝试的对象更新在映射文件中将'lazy'属性设置为false。似乎hibernate希望我在保存子对象之前刷新更新???
编辑(添加):
<休眠映射>
< class name =utils.message.Messagetable =messages>
< id name =idcolumn =message_id>
< generator class =native/>
< / id>
< property name =message_textcolumn =message_text/>
< property name =message_filecolumn =message_file/>
< property name =is_activecolumn =is_activetype =boolean/>
< property name =startcolumn =starttype =java.util.Date/>
< property name =endcolumn =endtype =java.util.Date/>
< property name =last_updatedcolumn =last_updatedtype =java.util.Date/>
< / class>
< / hibernate-mapping>
App在Spring环境中。修复:在Hibernate环境中运行更新。
I am getting the following exception when I try to update an object:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ......
Can anyone help???
The object that I am trying to update has the 'lazy' attribute set to false in the mapping file. Seems like hibernate is expecting me to save child objects before it flushes the update???
EDIT (ADDED):
<hibernate-mapping>
<class name="utils.message.Message" table="messages">
<id name="id" column="message_id">
<generator class="native" />
</id>
<property name="message_text" column="message_text" />
<property name="message_file" column="message_file" />
<property name="is_active" column="is_active" type="boolean"/>
<property name="is_global" column="is_global" type="boolean"/>
<property name="start" column="start" type="java.util.Date"/>
<property name="end" column="end" type="java.util.Date"/>
<property name="last_updated" column="last_updated" type="java.util.Date"/>
<many-to-one name="last_updated_by" class="utils.user.User" column="last_updated_by" lazy="false"/>
<many-to-one name="healthDepartment" class="utils.healthdepartment.HealthDepartment" column="health_department_id" lazy="false"/>
</class>
</hibernate-mapping>
App is in a Spring environment. Fix: to run update from within Hibernate environment.
这篇关于Hibernate异常帮助:TransientObjectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!