[英]How do I know if Grails domain POJO was changed since its retrieval?
I am patching a domain object in my code. 我在我的代码中修补域对象。 At the end, I need to save the object but only if it has been actually changed.
最后,我需要保存对象,但只有在实际更改后才能保存。 Is it possible to avoid custom boolean flags having code like that?
是否有可能避免使用具有类似代码的自定义布尔标志?
User user = User.find(...)
if(maybe)
user.name = "John"
if(user.changed())
user.save()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.