Merge remote-tracking branch 'upstream/main' into wip/6.0
This commit is contained in:
commit
52b83829f1
|
@ -319,6 +319,13 @@ public interface SharedSessionContractImplementor
|
|||
*/
|
||||
Object instantiate(String entityName, Object id) throws HibernateException;
|
||||
|
||||
/**
|
||||
* Instantiate the entity class of an EntityPersister, initializing with the given identifier.
|
||||
* This is more efficient than {@link #instantiate(String, Serializable)} but not always
|
||||
* interchangeable: a single persister might be responsible for multiple types.
|
||||
*/
|
||||
Object instantiate(EntityPersister persister, Object id) throws HibernateException;
|
||||
|
||||
/**
|
||||
* Execute a native SQL query, and return the results as a fully built list.
|
||||
*
|
||||
|
|
|
@ -153,12 +153,12 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
|
||||
@Override
|
||||
public Object get(Class entityClass, Object id) {
|
||||
return get( entityClass.getName(), id );
|
||||
return get( entityClass.getName(), id, LockMode.NONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Class entityClass, Object id, LockMode lockMode) {
|
||||
return get( entityClass.getName(), id, lockMode );
|
||||
return get( getFactory().getMetamodel().entityPersister( entityClass ), id, lockMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,10 +168,13 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
|
||||
@Override
|
||||
public Object get(String entityName, Object id, LockMode lockMode) {
|
||||
return get( getFactory().getMetamodel().entityPersister( entityName ), id, lockMode );
|
||||
}
|
||||
|
||||
protected Object get(final EntityPersister ep, final Serializable id, final LockMode lockMode) {
|
||||
checkOpen();
|
||||
|
||||
Object result = getFactory().getMetamodel().entityPersister( entityName )
|
||||
.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
Object result = ep.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
if ( temporaryPersistenceContext.isLoadFinished() ) {
|
||||
temporaryPersistenceContext.clear();
|
||||
}
|
||||
|
@ -255,9 +258,16 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object instantiate(String entityName, Object id) throws HibernateException {
|
||||
public Object instantiate(
|
||||
String entityName,
|
||||
Object id) throws HibernateException {
|
||||
return instantiate( getFactory().getMetamodel().entityPersister( entityName ), id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiate(EntityPersister persister, Object id) throws HibernateException {
|
||||
checkOpen();
|
||||
return getFactory().getMetamodel().entityPersister( entityName ).instantiate( id, this );
|
||||
return persister.instantiate( id, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -458,7 +468,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
throws HibernateException {
|
||||
checkOpen();
|
||||
if ( entityName == null ) {
|
||||
return getFactory().getMetamodel().entityPersister( guessEntityName( object ) );
|
||||
return getFactory().getMetamodel().entityPersister( object.getClass() );
|
||||
}
|
||||
else {
|
||||
return getFactory().getMetamodel().entityPersister( entityName ).getSubclassEntityPersister( object, getFactory() );
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
*/
|
||||
package org.hibernate.resource.transaction.backend.jta.internal;
|
||||
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.transaction.spi.DdlTransactionIsolator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;
|
||||
import org.hibernate.service.spi.ServiceRegistryAwareService;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.tool.schema.internal.exec.JdbcContext;
|
||||
|
||||
/**
|
||||
|
@ -18,15 +21,19 @@ import org.hibernate.tool.schema.internal.exec.JdbcContext;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JtaTransactionCoordinatorBuilderImpl implements TransactionCoordinatorBuilder {
|
||||
public class JtaTransactionCoordinatorBuilderImpl implements TransactionCoordinatorBuilder, ServiceRegistryAwareService {
|
||||
|
||||
public static final String SHORT_NAME = "jta";
|
||||
|
||||
private JtaPlatform jtaPlatform;
|
||||
|
||||
@Override
|
||||
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options) {
|
||||
return new JtaTransactionCoordinatorImpl(
|
||||
this,
|
||||
owner,
|
||||
options.shouldAutoJoinTransaction()
|
||||
options.shouldAutoJoinTransaction(),
|
||||
jtaPlatform
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -45,4 +52,10 @@ public class JtaTransactionCoordinatorBuilderImpl implements TransactionCoordina
|
|||
public DdlTransactionIsolator buildDdlTransactionIsolator(JdbcContext jdbcContext) {
|
||||
return new DdlTransactionIsolatorJtaImpl( jdbcContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
|
||||
this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,14 +74,15 @@ public class JtaTransactionCoordinatorImpl implements TransactionCoordinator, Sy
|
|||
JtaTransactionCoordinatorImpl(
|
||||
TransactionCoordinatorBuilder transactionCoordinatorBuilder,
|
||||
TransactionCoordinatorOwner owner,
|
||||
boolean autoJoinTransactions) {
|
||||
boolean autoJoinTransactions,
|
||||
JtaPlatform jtaPlatform) {
|
||||
this.transactionCoordinatorBuilder = transactionCoordinatorBuilder;
|
||||
this.transactionCoordinatorOwner = owner;
|
||||
this.autoJoinTransactions = autoJoinTransactions;
|
||||
|
||||
final JdbcSessionContext jdbcSessionContext = owner.getJdbcSessionOwner().getJdbcSessionContext();
|
||||
|
||||
this.jtaPlatform = jdbcSessionContext.getServiceRegistry().getService( JtaPlatform.class );
|
||||
this.jtaPlatform = jtaPlatform;
|
||||
|
||||
final SessionFactoryOptions sessionFactoryOptions = jdbcSessionContext.getSessionFactory().getSessionFactoryOptions();
|
||||
this.preferUserTransactions = sessionFactoryOptions.isPreferUserTransaction();
|
||||
|
|
Loading…
Reference in New Issue