我应该将我的 Grails 域关系转换为使用 Hibernate Bags 吗?
在 Grails 1.3.7 中,我花了相当多的时间根据 Burt 在 http://www.infoq.com/presentations/GORM-Performance
现在,Grails 2 支持 Hibernate 的 Bags,我正在考虑恢复我更改回 hasMany
/belongsTo
。
- 使用哪个选项将更加面向未来?
- 如果我坚持手动/显式实现,可能会出现哪些问题?
- 如果我切换到包?
- 与其他变体相比,这两种变体有什么优势吗?
请注意,该应用程序将在多年内实现长期改进(因此不会出现“部署后忘记”的情况) ':).
更新:一个主要问题是,如果我在应用程序上线后进行更改,在数据库中进行手动更改会带来多少麻烦。目前尚未发布,因此在上线之前是合理的。
更新:答案
在博客文章“Grails 2.0 中的 Hibernate Bags”中” 日期为 2011 年 11 月,Burt Beckwith 描述了 Grails 2 中的 Bags 问题并得出结论:
所以我想我又回到了之前演讲中提倡的方法; 不要在 Author 类中映射 Books 集合,而是添加一个 Author 字段改为 Book 类
所以答案是坚持使用转换后的(即非 set/-list/-bag)变体。
请投票支持重新打开此线程,以便它可以得到答复&以正确的方式接受。
In Grails 1.3.7 I've spent quite some time to convert my domain class relations according to Burt's suggestions in http://www.infoq.com/presentations/GORM-Performance
Now, Grails 2 supports Hibernate's Bags and I am considering to revert my changes back to hasMany
/belongsTo
.
- With which option will I be more future-proof?
- Which problems might arise if I stick to the manual/explicit implementation?
- Which problems might arise if I switch to Bags?
- Is there any advantage in either variant compared to the other?
Note that the application will see long-term improvements over many years (so no 'deploy-and-forget' :).
UPDATE: One main concern is how much hassle it would incur in regards to manual changes in the database if I did the change after the app goes live. Currently it is unreleased, so it poses to be reasonable before Go-Live.
UPDATE: THE ANSWER
In the blogpost 'Hibernate Bags in Grails 2.0' dated November 2011, Burt Beckwith describes issues with Bags in Grails 2 and concludes:
So I guess I’m back to advocating the approach from my earlier talks;
don’t map a collection of Books in the Author class, but add an Author
field to the Book class instead
So the answer is to stick with the converted (i.e. non-set/-list/-bag) variant.
Please vote for re-opening this thread so it may be answered & accepted in correct fashion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论