dinsdag 16 augustus 2011

Using Hibernate Envers with PlayFramework

PlayFramework is a very easy framework to use and to learn. I'm currently working on my OpenHAP project to make Hibernate Envers work. By default the Envers lib is not included in the Play distribution (version 1.2.2). To enable Envers you will have to follow a few simple steps:

  1. Add the envers jarfile to your project. To do this open your dependencies.yml file and add the following lines afther the -play entry:
    - org.hibernate -> hibernate-envers 3.6.1.Final:
          transitive: false
    I have added the transitive: false to ensure no other libs are added to my lib folder. I do not need these.
  2. Stop your play project via the commandline and execute the command:
    ./play dependencies [Your-projectname-here] --verbose
    The verbose is optional to see what Play is actually doing. This might be usesfull when play is not able to download the jarfile.
  3. hibernate.ejb.event.post-insert=org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener
  4. If needed update your eclipse project by calling the eclipsify command.
  5. We now have all required resources in place and can start annotating our Model classes with the @Audited annotations. For info on what you can do with this I suggest you take a look at the Hibernate manual envers section. You can find that here

Now you are ready to start working on your revisions. In the next post I'll work out a simple example using this approach.

woensdag 8 december 2010

Welcome to my blog

This is my first ever blogpost. My intention is to post useful java, semantics, and IDE related experiences on this blog. Keep checking this blog for new posts.