How to manage object revisions in Grails?
Asked Answered
P

3

17

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.

Planimeter answered 25/8, 2010 at 10:32 Comment(1)
@Pascal Thx but I would have preferred a nice answer :)Planimeter
P
9

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)

Planimeter answered 30/8, 2010 at 21:42 Comment(4)
Very interesting! Thanks for posting your findings! I like GIT, but I'm a very unsure whether it would be a good idea in this context.Calicle
Fabien, your friend suggested a tool which was designed for a very different type of task: versioning code (as opposed to database data). The two domains have nothing in common so you would do well to focus on other options (envers looking quite promissing, as far as I can tell).Gillead
@Tomislav I'm pretty sure that my friend has already implemented a DB versioning system using GIT. What is the difference between versioning code vs text?Planimeter
the question is if it should (rather than "can") be done. You need to version articles managed using a web app. This means being able to determine the number of versions, retrieve an individual version and so on. If you keep your data in a DB, you already have a DAL to communicate with the DB. Introducing an SCM to version the data would introduce a parallel DAL and require that you write lots of hackish code (to put it mildly) which would dump the DB, commit/retrieve to/from git...and so on. The proper approach would be to use the same DAL to work with the same kind of data.Gillead
J
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 :)

Jeth answered 30/8, 2010 at 20:42 Comment(0)
D
2

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.

Diphenylamine answered 31/10, 2011 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.