Hi,
We have an application in which we are trying to integrate Hibernate. I've read some very good posts here that talking about this, however they all (same as hibernate in action book) suggest using transaction for everything. I've been reading IBM articles about LTC in J2EE environment and they also recommend always execute db-related code in global transaction (which implies using shareable connection).
QUESTION: Nothing I have read point to not using global transaction as being a problem. Is it ?
I do know that using LTC will actually get me multiple physical connections when ds.getConnection() is called unless I close connection handle, but is it necessary a bad thing? (it could be if we call getConnection() multiple time in the same request without closing handles, but we try to avoid this)
QUESTION: How much overhead is it to always create a transaction? Even if we endup never hitting database (we have caching in place)?
APPLICATION: our app does not have EJBs - everything runs in WEB container and we don't use UserTransaction (we are however are starting to introduce EJBs for certain things). We have an implementation of PersistenceManager that we put together after reading Hibernate In Action book (which was the first step), and we are trying now to cleanup/fix the rest of the code that was originally executed in LTC transaction (second step - currently we wrapped all that code in transactions).
QUESTION: The reason I am looking at the second step is because I thought creating global transaction is an overhead. Is it?
One of the solution we are looking at is as follows: keep using PersistenceManager and wrap every Manager-layer method in transaction (and let PersistenceManager do reference counting to determine when actually to start/commit/rollback transactions). We are considering using AspectJ to wrap each method in transaction to keep the code clean.
Sorry for the long message, however this is all in my head spinning and will drive me crazy until I understand indepth every plus and minus to every approach. In the meantime, I am rereading Hibernate In Action and Professional EJB 2.0 sections that deal with transactions and connections
thanks a lot for the help
Andrey
|