[英]hibernate.TransientObjectException:object references an unsaved transient instance-save the transient instance before flushing-after hibernate upgrade
I get the error after upgrading to hibernate 3.6.0.FINAL but it was working with 3.3.2.GA 升级到休眠3.6.0.FINAL后出现错误,但它与3.3.2.GA一起使用
My problem is similar to https://forum.hibernate.org/viewtopic.php?p=2452617 我的问题类似于https://forum.hibernate.org/viewtopic.php?p=2452617
In that case they have set cascade="all" to solve the problem. 在那种情况下,他们设置了cascade =“ all”来解决问题。
But In my case, I dont want to update the referenced entity. 但是就我而言,我不想更新引用的实体。 I dont have bi directonal, relation, it is just a many to one.
我没有双向关系,这只是一对多。 Most of the similar Question posted here, suggest to do a cascade all, but in my case it dont want to cascade.
这里发布的大多数类似问题,建议全部进行级联,但在我的情况下,它不想级联。
my mapping 我的地图
<class name="org.hmil.ams.com.model.MyUserDetails" table="CMUPMST_TB">
<id name="username" column="UPMST_USER_NAME" type="java.lang.String"
unsaved-value="0">
<generator class="assigned" />
</id>
<property name="password" column="UPMST_USER_PWD" type="java.lang.String"
not-null="true" />
<property name="UPMST_ROLE_ID" type="long" not-null="true" />
<many-to-one name="UPMST_ROLE" fetch="join" cascade="none"
insert="false" update="false" class="org.hmil.ams.setup.model.CodeMst">
<column name="UPMST_ROLE_ID" />
</many-to-one>
</class>
I am using Spring BlazeDS/ flex,My objects are detached. 我正在使用Spring BlazeDS / flex,我的对象已分离。 Now when I try to save the newly created MyUserDetails Entity, It says there is transient instance of CodeMst, (I am not updating the entity, but may be BlazeDS while it deserializes the newly Created MyUserDetail, it is instantiating the referenced CodeMst Entity, with null values, this may be causing the issue, but same code was working before upgrade ) Any help to solve this is appreciated.
现在,当我尝试保存新创建的MyUserDetails实体时,它表示存在CodeMst的瞬时实例,(我不更新实体,但是在反序列化新创建的MyUserDetail时可能是BlazeDS,它实例化了引用的CodeMst实体, null值,这可能是导致问题的原因,但是在升级之前,相同的代码仍在工作)解决此问题的任何帮助。
I actually found a solution here: https://hibernate.atlassian.net/browse/HHH-5908 我实际上在这里找到了解决方案: https : //hibernate.atlassian.net/browse/HHH-5908
Deployed the patch. 部署补丁。 I just added the same fix for the TypeHelper.findDirty method (line 287)
我刚刚为TypeHelper.findDirty方法添加了相同的修复程序(第287行)
OLD: final boolean[][] includeColumns,
NEW: final boolean[] includeProperties, final boolean[][] includeColumns,
And then in AbstractEntityPersister.findDirty (line 3408): 然后在AbstractEntityPersister.findDirty中(第3408行):
OLD: propertyColumnUpdateable,
NEW: getPropertyUpdateability(), propertyColumnUpdateable,
Update: The hibernate fix that broke this was https://hibernate.atlassian.net/browse/HHH-2350 更新:打破此问题的休眠修复程序是https://hibernate.atlassian.net/browse/HHH-2350
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.