How to manage object revisions in Grails?

流过昼夜 提交于 2020-01-01 04:04:31

问题


I need to implement a revision system for articles in my grails web app. After searching grails forum, stackoverflow, grails plugins and googling internet, I have ended up with 3 options:

Option 1 - Using the grails Envers plugin (see http://code.google.com/p/grails-envers-plugin/). Has anyone used it successfully? Or using Envers without the plugin (see here) but how can I make it work with GORM?

Option 2 - Using the Gvers plugin I have found out here: https://github.com/ziftytodd/gvers. I never heard anyone using it, so is there anybody who have ever used it successfully?

Option 3 - Built -in mechanism. Weceem has created a versioning system for any content of the Weceem CMS. I can draw my inspiration from the logic of the code and design of this great application but it seems like overkill and I don't really like using non-standard solutions.

So my question, what do you advise me to do ? Have you ever used any of these options ?

Thank you very much for your insights.


回答1:


Since I didn't get any answers during the days following my question, we have started investigating all of the options and came to the following results/conclusions :

  1. Envers plugin : while Envers is a well-established way to handle object revisions and auditing with Hibernate (as pointed out by Vadeg), there is no such out-of-the-shelf solution for grails. Envers plugin is stricly useless and a dead-never-born project. Therefore, using Envers with GORM is still not possible directly BUT I believe that there is a space for an Envers Plugin (maybe part of grail 2.0 ?) since Envers is now integral part of Hibernate core modules. However, we didn't have time to implement such a solution (which is by far the best one when you have enough time and resources ahead of you)...so we dropped it.

  2. Gvers plugin : Surprisingly this plug-in is working like a charm even if it seems that no one is using it in GRAILS world (even the plugin creator that has an invalid email!). Seems risky to go with it but if your requirements are low (like a basic versioning system), you should go with it..

  3. Built-In System : except if you are building a CMS system with very specific needs OR at the contrary something very simple, I would not go for it in any other cases. Weceem is very-well implemented with plenty of examples for CMS content revisions, but even for this, it's a pity that they don't use Envers instead. No need to reinvent the wheel...better to improve existing Ferrari, no?

  4. VCS System : one friend has suggested me to use existing solutions that are built especially for this kind of tasks : Version control System of course!! Actually GIT seems to be the perfect candidate : fast, reliable, alomst-free repositories available at your disposal. Actually this is perfect solution. My only problem : well, I don't know how to use Git (and even less its API) and again I don't have time.

Bottom Line

I will certainly use Gvers but if you are familiar with Git or if you feel comfortable with GORM and Hibernate, go for building a grail plugin (either based on Git or Envers)




回答2:


I've used Envers in project with Hibernate and it works fine. GORM is based on the Hibernate, so I think there is no problem with it.

First of all, you need to decide what kind of versioning you need? Do you need to rollback object graph changes or you need to look after some fields? Sometimes it's better to make some small local implementation rather than injecting huge library.

If you need to revision graph of objects, Envers is a good choice. If you need to make revision of one field, DIY :)




回答3:


Lucas Ward's plugin works. Confirmed with Grails 1.3.7 The important thing is to ensure entity updates are within transaction as envers depends on it. Just to remind Grails controllers aren't transactional by default.



来源:https://stackoverflow.com/questions/3564936/how-to-manage-object-revisions-in-grails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!