Coldfusion ORM/Hibernate StaleStateException
每次在 Coldfusion 9.01 ORM 上执行非常简单的保存操作时,我都会收到以下错误:
Hibernate 操作中的异常。 更新/删除的行不存在或者会话包含过时的数据。根本原因:org.hibernate.StaleStateException:批量更新从更新 [0] 返回意外的行计数;实际行数:0;预期:1
以下代码实际上会更新数据库中的对象,但此错误出现在页面底部,大概是当 Coldfusion 在请求结束时自动调用 ormFlush() 时。
<cfscript>
myDeal = entityloadbypk('serviceCategory',1);
myDeal.setScName('Automotive1');
EntitySave(myDeal);
writedump(myDeal);
</cfscript>
这是我正在处理的对象,但是在处理多个对象时也会出现同样的问题。
<cfscript>
/**
* @persistent
* @table y_serviceCategories
*/
component{
property name="scID" fieldtype="id" datatype="int" generator="native";
property string scName;
property priority;
property name="serviceSubCategory" fieldtype="one-to-many" cfc="serviceSubCategory" fkcolumn="scID";
public array function getSubCategoryByPriority(){
return EntityLoad("serviceSubCategory", {scID=getscID()}, "Priority ASC");
}
}
</cfscript>
我当前的想法是,Hibernate 批处理中存在一些过时的对象(与代码中的对象无关),每次 Hibernate 运行添加/更新批处理时都会失败。请帮忙!!!
I'm getting the following errors every time I perform very simple save operations on Coldfusion 9.01 ORM:
Exception in Hibernate operation.
Either the updated/deleted row does not exist or the session contained stale data. Root cause :org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
The following code will actually update the object in the database, but this error appears at the bottom of the page, presumably when Coldfusion automatically calls ormFlush() at the end of the request.
<cfscript>
myDeal = entityloadbypk('serviceCategory',1);
myDeal.setScName('Automotive1');
EntitySave(myDeal);
writedump(myDeal);
</cfscript>
Here is the object I'm working with, however this same problem occurs when doing this with multiple objects.
<cfscript>
/**
* @persistent
* @table y_serviceCategories
*/
component{
property name="scID" fieldtype="id" datatype="int" generator="native";
property string scName;
property priority;
property name="serviceSubCategory" fieldtype="one-to-many" cfc="serviceSubCategory" fkcolumn="scID";
public array function getSubCategoryByPriority(){
return EntityLoad("serviceSubCategory", {scID=getscID()}, "Priority ASC");
}
}
</cfscript>
My current thought is that there is some stale object (unrelated to the object in the code) in the Hibernate batch that fails every time Hibernate runs an add/update batch. Please help!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了获得更好的效果,请尝试
在之后添加
For kicks, try adding
after