spring 尝试使用空实体创建 saveOrUpdate 事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1378993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
attempt to create saveOrUpdate event with null entity
提问by Rafael
I have a GWT app that makes an RPC call to a server to save/create a new entity. However, the Spring-Hibernate back-end throws an exception with the following error message:
我有一个 GWT 应用程序,它向服务器发出 RPC 调用以保存/创建新实体。但是,Spring-Hibernate 后端会抛出异常并显示以下错误消息:
attempt to create saveOrUpdate event with null entity
I'm not sure what that means. What's null? If it's a new entity I am saving, I am expecting to have the idfield be nullor possibly 0, and then have hibernate fill it. Is this expectation correct?
我不确定这意味着什么。什么是空?如果它是我要保存的新实体,我希望该id字段为null或可能为0,然后让休眠填充它。这个预期正确吗?
回答by André Chalella
null entitycould mean that saveOrUpdate()is actually receiving nullas an argument, ie:
null entity可能意味着saveOrUpdate()实际上是null作为参数接收,即:
session.saveOrUpdate(null);
If you're using serialization to pass to object to a remote location (you mentioned RPC), perhaps you should check if serialization is working correctly. Something tells me that failing to serialize might end up with a null reference being passed.
如果您使用序列化将对象传递给远程位置(您提到了 RPC),也许您应该检查序列化是否正常工作。有些东西告诉我,序列化失败可能会导致传递空引用。

