如何使用 Spring Roo 创建没有 @Version 字段的 @Entity?
我使用 Spring Roo 和 JPA (Hibernate) 作为我的实体模型。我不想在某些实体中拥有 @Version 字段。我怎样才能做到这一点?
I am using Spring Roo with JPA (Hibernate) for my entity model. I don't want to have a @Version field in some entities. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
生成实体后,在退出 roo shell 之前,使用以下内容修改实体 java 源文件
After the generation of entity, before exiting roo shell, modify entity java source file with the following
尝试在 roo 中使用以下注释
Try using below annotation in roo
Roo 实体命令采用
--versionField
和“--versionColumn”参数。我认为设置--versionField=""
应该可以满足您的要求。Roo entity command takes
--versionField
and '--versionColumn' parameters. I think setting--versionField=""
should do the trick for you.没有特别的理由从 Roo 实体中删除
@Version
,它可以避免分布式 Web 应用程序可能遇到的并发数据修改问题的麻烦。There is no particular reason to remove
@Version
from a Roo entity, it saves the hassle of concurrent data modification issues which you might encounter with a distributed web application.