Is the following possible and save:
(1) I use OSIV, with a single transaction / session per request,
I implement this with a servlet filter.
(2) I implement my own ConnectionProvider, which retrieves a java.sql.Connection from a datasource.
Now my question is, can I safely execute queries on the same java.sql.Connection through plain JDBC (without Hibernate)
(in the same transaction Hibernate uses),
or will this conflict with Hibernate (or is this only possible with JDBC transaction demarcation)?
If I understood correctly, the Hibernate Session class runs in a seperate thread?
The reason why I want to do this:
We have applications which want to go to database with the same datasource using plain JDBC, using a java.sql.Connection which spans the whole request,
transaction management is done using plain JDBC demarcation.
If I use a seperate connection (not the one Hibernate uses) from the same datasource pool, we might get deadlocking problems if two threads have obtained the last two remaining connections, and then both request a second (but the pool is empty).
Or would a better solution be:
Use two datasources: one for Hibernate, one for plain JDBC? This would solve the deadlocking problem.
Problem is then that there are actually two somewhat unrelated transactions running concurrently.
To make things more complicated:
sometimes someone wants to do an intermediate commit,
so this really is difficult, because I want to have a single transaction/session.
_________________ Sincerely,
Joost Winne
|