Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] JDBC connection, transaction and EntityManager...

Well its complicated.

If you are using a JTA EntityManager with a JTA
Connection/DataSource/connection pool, then each JTA transaction will use a
single JDBC connection and Oracle session.  A JTA JDBC Connection returned
from a JTA DataSource will use a different Oracle session for each JTA

If you are not using JTA, then in EclipseLink the EntityManager will have a
read and a write connection pool.  The read connection pool will be used for
any read, until the first write is triggered in the EntityManager
transaction context (such as a flush(), or update-all, native-SQL query,
etc.).  Then a single JDBC connection (and Oracle session) from the write
connection pool will be used for the duration of the EntityManager

You can also force the EntityManager to always use a single write connection
by setting the "eclipselink.jdbc.exclusive-connection.mode"="Always"
persistence or EntityManager property.

You can also use a read connection pool in JTA by setting the
non-jta-datasource property.

markus hahn wrote:
> Hi, 
> Two short questions referring to relation between connection, transaction
> and EntityManager and DB session: 
> does the JDBC connection stay the same during one transaction started by a
> EntityManager? And does a JDBC connection always operate on one DB session
> (on Oracle Database)? 
> Thanks in advance, Markus 

----- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top