[quote]I'm currently using the TransactionProxyFactoryBean to handle transaction using Hibernate in my application.After viewing the logging, I noticed that a new transaction seems to be started/closed for every call made to the session.[quote]
Please post your session factory, datasource, transaction manager and all other related bean configurations+ an example method.
I guess you missconfigured the hibernate transaction manager some how. It looks like an unnormal behaviour.
Since you asked, here is a little Transaction snippet to get you started on managing transactions explicitly.
Begin a transaction (start a new one if none exist):
Code:
TransactionStatus transaction=getTransactionManager().
getTransaction(new DefaultTransactionDefinition());
To end the transaction:
Code:
getTransactionManager().commit(transaction);
Note: The transaction is rolled back even when commiting if the rollback flag is set of the TransactionStatus object.
For testing you may also surround your code by an explicit transaction using the above call. If there are still a lot of transactions started than you have a missconfiguration.
Another issue is wether the reported transactions are real transations or just nested ones. You know nested transactions maybe are logged, too but they do not issus a real transaction. So please provide your log files as well.
Is there an easy way to accomplish this?
See the above code snippet. It's quite simple and easy to use. Beside the declarative transaction specification using AOP should also work... .