Hi,
I'm using the ThreadLocal pattern with Hibernate.
The architecture is jsp->Action->Delegate->EJB->Hibernate/DAO
I need to connect to two datasources, but not within the same transaction.
My first transaction begins at the ejb layer, (connects to a datasource1) and later ends at the ejb. Then the second transaction begins again at the ejb (and tries to connect to a second datasource -datasource2).
My first transaction goes through fine, but when I try to get a connection in the second transaction, it throws up with the exception stating that I'm trying to connect to multiple databases within one transaction. Which is not correct because my first transaction was completed before I started the second. I've done a session.flush() and session.disconnect() .
The same data access works fine when I replace Hibernate with DAO.
Would anyone know why this happens? Do I need to do anything more to communicate to Hibernate that this is a new transaction?
Thanks in advance.
|