Jul 26th, 2009, 07:10 AM
Hibernate Search and Envers - ideas needed
Firstly, congratulations on the release of ROO. I have just started playing around with it today and it looks very interesting indeed.
I have a new project that I would like to give a ROO a run on. I am keen to use both Jboss Envers as an audit layer and also Hibernate Search. I am guessing that these libraries could be introduced as add-ons at somepoint. Presumably to use these libs at the moment, I will need to introduce a layer of Repositories that can handle the extra finder methods that I will need to make use of Envers and Search; or should I be looking at doing something a little fancier with AspectJ? (I have no experience with AspectJ just yet).
Any pointers are much appreciated.
Jul 27th, 2009, 06:50 AM
Don´t take me too serious since i´m not part of Roo´s team but as long as i know you can add whatever you want just as you do in a normal java project, roo uses aspectj for adding functionality to your code but the final result is a usual aspectj unaware java class so you don´t need to worry about aspectj.
Use any libraries you want and forgot aspectj
Jul 27th, 2009, 07:33 PM
I'm not sure how Envers works, but in the past whenever I have built these sort of audit solutions I have tried to hook into the Hibernate event model directly. It's quite an elegant approach, as you find out every read/update/create operation - even those that happen via transparent persistence of entities with long navigation trees (eg foo.getBar().getCar().setComment("blah")). I find intercepting calls to repository or services layer methods a little less elegant, as while you can determine the most obvious thing happening (eg repo.update(Person)), you generally don't determine if some nested property within Person was modified.
Jul 27th, 2009, 09:38 PM
After a quick look, it does indeed look like Envers uses the Hibernate event mode:
Cool! I've had to do the Hibernate interceptors to handle this so many times in past applications.
I'm not familiar enough with Roo to figure out if there's any problem with introducing Envers into the mix - but the generated persistence.xml looks like it could be easily modified as necessary. No?
Jul 28th, 2009, 02:21 AM
Yes, that's right. It is just a case of configuring persistence.xml with the event listeners and of course adding the dependency from the Jboss repository.
Entities can then simply be annotated with @Audited. Envers then allows entities to be queried for in a temporal fashion and return a Snaphot. These queries would appear in additional hand-crafted Repositories for now, but I guess, later, they could exisit as dynamic finders in Roo via an add-on?
Tags for this Thread