Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes stand-alone java app and hibernate transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "stand-alone java app and hibernate transactions" Watch "stand-alone java app and hibernate transactions" New topic
Author

stand-alone java app and hibernate transactions

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi All,

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.

Thanks,


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stand-alone java app and hibernate transactions
 
Similar Threads
transaction related exception handling design strategy
J2EE Data Access Lyer Design suggestions...
Implementing Hibernate on legacy system
spring transaction management only
Hibernate transactions