何时不在 Grails 域类中使用版本号?
在我之前的 Grails 项目(高交易量)中,我对一对多和多对多关系的过时对象异常有过可怕的经历。
我基本上保存了 Facebook 好友的个人资料(包括学校、雇主的整个个人资料),大多数时候我会一起保存 1000 个用户个人资料。我通过从学校和雇主域类中删除版本号解决了大部分问题,因为该数据大部分是固定的,并且不需要为每次保存的经验或教育增加版本。由于日程安排很紧,我必须让事情正常进行,并且我从整个用户对象层次结构中删除了版本号,因为我仍然会遇到一些过时的对象异常。
那么,我仍然对何时不在域类中使用版本一无所知?
In my previous Grails project(high transaction volume), I had horrifying experience with Stale Object Exceptions with 1 to many and many to many relationships.
I was basically persisting Facebook friends profile (entire profile with School, Employers) and most of the times i was saving 1000 user profiles together. I solved most of the issues by removing version no from School and Employer domain class because that data is mostly fixed and there was no need to increment version for every save of experience or education. Because of tight schedules, i had to make things work and i removed version no from entire user object hierarchy because i still used to get some Stale object Exceptions.
So, i am still in dark on when not use version in domain classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不一定认为版本是您的问题,这是 grails 默认处理集合的方式。 hasMany 和belongsTo 开箱即用的方式最终会从数据库加载比您几乎需要的更多的东西(从而导致更多的东西变得陈旧)。
Burt Beckwith 在这个关于高级 GORM 的视频中做得比我好得多。强烈推荐观看。
I don't necessarily think it's versions that are your problems, its the way that grails handles collections by default. The way hasMany and belongsTo work out of the box ends up loading a LOT more than you almost ever need from the DB (thus leading to a lot more things that are going to be stale).
Burt Beckwith does a much better job than I can in this video on Advanced GORM which I'd highly recommend watching.