HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (fix test failures)
This commit is contained in:
parent
68bde01676
commit
b67b5866ac
|
@ -25,7 +25,6 @@ import org.junit.Test;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.hibernate.userguide.util.TransactionUtil.doInJPA;
|
import static org.hibernate.userguide.util.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +55,7 @@ public class ManualFlushTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
entityManager.persist(person);
|
entityManager.persist(person);
|
||||||
|
|
||||||
Session session = entityManager.unwrap( Session.class);
|
Session session = entityManager.unwrap( Session.class);
|
||||||
session.setFlushMode( FlushMode.MANUAL);
|
session.setHibernateFlushMode( FlushMode.MANUAL );
|
||||||
|
|
||||||
assertTrue(((Number) entityManager
|
assertTrue(((Number) entityManager
|
||||||
.createQuery("select count(id) from Person")
|
.createQuery("select count(id) from Person")
|
||||||
|
|
|
@ -419,6 +419,7 @@ public class ProcedureCallImpl<R>
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
LOG.debugf( "Preparing procedure call : %s", call );
|
||||||
final CallableStatement statement = (CallableStatement) getSession()
|
final CallableStatement statement = (CallableStatement) getSession()
|
||||||
.getJdbcCoordinator()
|
.getJdbcCoordinator()
|
||||||
.getStatementPreparer()
|
.getStatementPreparer()
|
||||||
|
@ -596,7 +597,7 @@ public class ProcedureCallImpl<R>
|
||||||
getProducer().checkOpen( true );
|
getProducer().checkOpen( true );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
registerParameter( (ParameterRegistrationImplementor) registerParameter( position, type, mode ) );
|
registerParameter( position, type, mode );
|
||||||
}
|
}
|
||||||
catch (HibernateException he) {
|
catch (HibernateException he) {
|
||||||
throw getExceptionConverter().convert( he );
|
throw getExceptionConverter().convert( he );
|
||||||
|
|
|
@ -123,7 +123,7 @@ public interface QueryProducer {
|
||||||
*
|
*
|
||||||
* @see javax.persistence.EntityManager#createNativeQuery(String,Class)
|
* @see javax.persistence.EntityManager#createNativeQuery(String,Class)
|
||||||
*/
|
*/
|
||||||
NativeQuery createNativeQuery(String sqlString, Class resultClass);
|
<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a NativeQuery instance for the given native (SQL) query using
|
* Create a NativeQuery instance for the given native (SQL) query using
|
||||||
|
|
|
@ -115,6 +115,9 @@ public abstract class AbstractProducedQuery<R> implements QueryImplementor<R> {
|
||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
this.parameterMetadata = parameterMetadata;
|
this.parameterMetadata = parameterMetadata;
|
||||||
this.queryParameterBindings = QueryParameterBindingsImpl.from( parameterMetadata, producer.getFactory() );
|
this.queryParameterBindings = QueryParameterBindingsImpl.from( parameterMetadata, producer.getFactory() );
|
||||||
|
|
||||||
|
// this.flushMode = producer.getHibernateFlushMode();
|
||||||
|
// this.cacheMode = producer.getCacheMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -224,10 +224,24 @@ public class NativeQueryImpl<T> extends AbstractProducedQuery<T> implements Nati
|
||||||
// apps, so we only do the flush if a transaction is in progress.
|
// apps, so we only do the flush if a transaction is in progress.
|
||||||
//
|
//
|
||||||
// NOTE : this was added for JPA initially. Perhaps we want to only do this from JPA usage?
|
// NOTE : this was added for JPA initially. Perhaps we want to only do this from JPA usage?
|
||||||
if ( getProducer().isTransactionInProgress() ) {
|
if ( shouldFlush() ) {
|
||||||
getProducer().flush();
|
getProducer().flush();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldFlush() {
|
||||||
|
if ( getProducer().isTransactionInProgress() ) {
|
||||||
|
FlushMode effectiveFlushMode = getHibernateFlushMode();
|
||||||
|
if ( effectiveFlushMode == null ) {
|
||||||
|
effectiveFlushMode = getProducer().getHibernateFlushMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( effectiveFlushMode != FlushMode.MANUAL ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int doExecuteUpdate() {
|
protected int doExecuteUpdate() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.sql.SQLException;
|
||||||
|
|
||||||
import org.hibernate.ConnectionAcquisitionMode;
|
import org.hibernate.ConnectionAcquisitionMode;
|
||||||
import org.hibernate.ConnectionReleaseMode;
|
import org.hibernate.ConnectionReleaseMode;
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.ResourceClosedException;
|
import org.hibernate.ResourceClosedException;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
@ -58,8 +57,11 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
||||||
this.observer = jdbcSessionContext.getObserver();
|
this.observer = jdbcSessionContext.getObserver();
|
||||||
this.resourceRegistry = resourceRegistry;
|
this.resourceRegistry = resourceRegistry;
|
||||||
|
|
||||||
this.connectionHandlingMode = jdbcSessionContext.getPhysicalConnectionHandlingMode();
|
this.connectionHandlingMode = determineConnectionHandlingMode(
|
||||||
validateConnectionHandlingMode( connectionHandlingMode, jdbcConnectionAccess );
|
jdbcSessionContext.getPhysicalConnectionHandlingMode(),
|
||||||
|
jdbcConnectionAccess
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
this.sqlExceptionHelper = jdbcSessionContext.getServiceRegistry()
|
this.sqlExceptionHelper = jdbcSessionContext.getServiceRegistry()
|
||||||
.getService( JdbcServices.class )
|
.getService( JdbcServices.class )
|
||||||
|
@ -70,18 +72,15 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateConnectionHandlingMode(
|
private PhysicalConnectionHandlingMode determineConnectionHandlingMode(
|
||||||
PhysicalConnectionHandlingMode connectionHandlingMode,
|
PhysicalConnectionHandlingMode connectionHandlingMode,
|
||||||
JdbcConnectionAccess jdbcConnectionAccess) {
|
JdbcConnectionAccess jdbcConnectionAccess) {
|
||||||
if ( connectionHandlingMode.getReleaseMode() == ConnectionReleaseMode.AFTER_STATEMENT ) {
|
if ( connectionHandlingMode.getReleaseMode() == ConnectionReleaseMode.AFTER_STATEMENT
|
||||||
// make sure the Connection access supports reacquisition...
|
&& !jdbcConnectionAccess.supportsAggressiveRelease() ) {
|
||||||
// NOTE we used to just swap it here with a more correct release-mode, but
|
return PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION;
|
||||||
// really this ought to be validated at a higher level...
|
|
||||||
if ( !jdbcConnectionAccess.supportsAggressiveRelease() ) {
|
|
||||||
throw new HibernateException(
|
|
||||||
"Connection provider reports to not support aggressive release, but ATER_STATEMENT releasing was requested" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connectionHandlingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogicalConnectionManagedImpl(
|
private LogicalConnectionManagedImpl(
|
||||||
|
|
Loading…
Reference in New Issue