Wednesday, December 28, 2011

Transaction Management with JBoss Seam + JPA (Hibernate) like Spring Framework

I'm a fan of using Spring framework for all my projects, but unfortunately on my current project, I have to add a module to an existing app already developed using JBoss Seam EJB3 and Hibernate, so this is what I did to work with the same model of ServiceImpl that Spring uses

This is the DAO (Existing) - I just added the save method
And this will be My Service (I will not include the Interfaces)

By doing this we have the same model of Tx Management - Just by adding the 1 annotation to the method!!! Cool Isn't it?
Also, in case that you want to make your Tx ReadOnly, just add this annotation to your method (also)
org.jboss.seam.annotations.ReadOnly


Unfortunately the documentation for JBoss Seam is really poor on this aspect, so If anybody finds anything that could be improved, please let me know)

No comments:

Post a Comment