TopLinkTransactionObject txObject = (TopLinkTransactionObject) transaction;
return (txObject.getSessionHolder() != null);
}
protected void doBegin(Object transaction, TransactionDefinition definition) {
Session session = null;
try {
if (!definition.isReadOnly()) {
logger.debug("Creating managed TopLink Session with active UnitOfWork for read-write transaction");
session = getSessionFactory().createManagedClientSession();
}
else {
logger.debug("Creating plain TopLink Session without active UnitOfWork for read-only transaction");
session = getSessionFactory().createSession();
}
if (logger.isDebugEnabled()) {
logger.debug("Opened new session [" + session + "] for TopLink transaction");
}
TopLinkTransactionObject txObject = (TopLinkTransactionObject) transaction;
txObject.setSessionHolder(new SessionHolder(session));
txObject.getSessionHolder().setSynchronizedWithTransaction(true);
// Check isolation level.
switch (definition.getIsolationLevel()) {
case TransactionDefinition.ISOLATION_READ_UNCOMMITTED:
// TODO warn when queries are executed without the conformResultsInUnitOfWork setting
break;
case TransactionDefinition.ISOLATION_REPEATABLE_READ:
// TODO warn when queries are executed against a read-only Session
break;
case TransactionDefinition.ISOLATION_SERIALIZABLE:
// TODO warn if the TransactionIsolation settings on the DatabaseLogin are wrong
break;
}
// Register transaction timeout.
int timeout = determineTimeout(definition);
if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) {
txObject.getSessionHolder().setTimeoutInSeconds(timeout);
}
// Enforce early database transaction for TopLink read-write transaction,
// unless we are explicitly told to use lazy transactions.
if (!definition.isReadOnly() && !isLazyDatabaseTransaction()) {
session.getActiveUnitOfWork().beginEarlyTransaction();
}
// Register the TopLink Session's JDBC Connection for the DataSource, if set.
if (getDataSource() != null) {
Connection con = getJdbcConnection(session);