This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a stand-alone java app (no UI, no containers, no Spring) but we are using a layered approach internally for this app.
Following is how we maintain the layers within this stand-alone java app
Service Orchestration --> Service(or Manager layer) --> DAO --> Hibernate (ORM) -->Oracle
The Service Orchestration layer as the name suggests orchestrates call to various services as part of the business flow of this app.
The services(Manager layer) in turn have business logic chunks and also have data handling code like grab and aggregate data as part of the business logic related activities.
The DAO we use is a generic DAO (java 5 generics approach) on top of Hibernate
We also need transaction handling. My question where do have all the transaction handling (beginTransaction, endTransaction, commit, rollback).
Ideally I feel The Manager layer is best but I was a bit skeptical of invading the Manager layer with all Hibernate transaction api code usage.
Is there a way I can neatly encapsulate the transaction handling and inject it in Manager layer surrounding the DAO calls rather than verbose beginTransaction - commit/rollback - endTransaction - transaction related exception handling code in the Manager layer.
The other approach I have seen is having a HibernateUtil class which has all transaction related logic and comes into play post DAO layer. This approach works when the business logic is simple dealing with persistence of a single entity but in case of complex business logic involving multiple dao's (entities) the transactions need to incept at a layer above.
Let me know your thoughts.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: stand-alone java app and hibernate transactions