HHH-16008 promote joinTransaction() and isJoinedToTransaction() to SharedSessionContract
so they are available on a StatelessSession
This commit is contained in:
parent
436527b4ba
commit
dcc05b8c6c
|
@ -64,9 +64,30 @@ public interface SharedSessionContract extends QueryProducer, Closeable, Seriali
|
|||
* Get the {@link Transaction} instance associated with this session.
|
||||
*
|
||||
* @return a Transaction instance
|
||||
*
|
||||
* @see jakarta.persistence.EntityManager#getTransaction()
|
||||
*/
|
||||
Transaction getTransaction();
|
||||
|
||||
/**
|
||||
* Join the currently-active JTA transaction.
|
||||
*
|
||||
* @see jakarta.persistence.EntityManager#joinTransaction()
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
void joinTransaction();
|
||||
|
||||
/**
|
||||
* Check if the session is joined to the current transaction.
|
||||
*
|
||||
* @see #joinTransaction()
|
||||
* @see jakarta.persistence.EntityManager#isJoinedToTransaction()
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
boolean isJoinedToTransaction();
|
||||
|
||||
/**
|
||||
* Obtain a {@link ProcedureCall} based on a named template
|
||||
*
|
||||
|
|
|
@ -284,6 +284,16 @@ public class SharedSessionDelegatorBaseImpl implements SharedSessionContractImpl
|
|||
return delegate.getTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinTransaction() {
|
||||
delegate.joinTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinedToTransaction() {
|
||||
return delegate.isJoinedToTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateCriteriaBuilder getCriteriaBuilder() {
|
||||
return delegate.getCriteriaBuilder();
|
||||
|
|
|
@ -84,6 +84,7 @@ import org.hibernate.resource.jdbc.internal.EmptyStatementInspector;
|
|||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
@ -539,6 +540,31 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinTransaction() {
|
||||
checkOpen();
|
||||
if ( !getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
|
||||
log.callingJoinTransactionOnNonJtaEntityManager();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
getTransactionCoordinator().explicitJoin();
|
||||
}
|
||||
catch ( TransactionRequiredForJoinException e ) {
|
||||
throw new TransactionRequiredException( e.getMessage() );
|
||||
}
|
||||
catch ( HibernateException he ) {
|
||||
throw getExceptionConverter().convert( he );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinedToTransaction() {
|
||||
checkOpen();
|
||||
return getTransactionCoordinator().isJoined();
|
||||
}
|
||||
|
||||
protected void delayedAfterCompletion() {
|
||||
if ( transactionCoordinator instanceof JtaTransactionCoordinatorImpl ) {
|
||||
( (JtaTransactionCoordinatorImpl) transactionCoordinator )
|
||||
|
|
|
@ -127,7 +127,6 @@ import org.hibernate.query.SelectionQuery;
|
|||
import org.hibernate.query.UnknownSqlResultSetMappingException;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
|
@ -2748,31 +2747,6 @@ public class SessionImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinTransaction() {
|
||||
checkOpen();
|
||||
if ( !getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
|
||||
log.callingJoinTransactionOnNonJtaEntityManager();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
getTransactionCoordinator().explicitJoin();
|
||||
}
|
||||
catch ( TransactionRequiredForJoinException e ) {
|
||||
throw new TransactionRequiredException( e.getMessage() );
|
||||
}
|
||||
catch ( HibernateException he ) {
|
||||
throw getExceptionConverter().convert( he );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoinedToTransaction() {
|
||||
checkOpen();
|
||||
return getTransactionCoordinator().isJoined();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> clazz) {
|
||||
|
|
Loading…
Reference in New Issue