Fix FlushMode
This commit is contained in:
parent
1e6a601795
commit
affa6a086c
|
@ -150,6 +150,7 @@ import static org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting.det
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
* @author Chris Cranford
|
||||||
*/
|
*/
|
||||||
public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( SessionFactoryImpl.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( SessionFactoryImpl.class );
|
||||||
|
@ -551,7 +552,14 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
else {
|
else {
|
||||||
builder.autoJoinTransactions( false );
|
builder.autoJoinTransactions( false );
|
||||||
}
|
}
|
||||||
return builder.openSession();
|
|
||||||
|
final Session session = builder.openSession();
|
||||||
|
map.keySet().forEach ( key -> {
|
||||||
|
if ( key instanceof String ) {
|
||||||
|
session.setProperty( (String) key, map.get( key ) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -211,6 +211,7 @@ import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_STORE_MODE;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
|
* @author Chris Cranford
|
||||||
*/
|
*/
|
||||||
public final class SessionImpl
|
public final class SessionImpl
|
||||||
extends AbstractSessionImpl
|
extends AbstractSessionImpl
|
||||||
|
@ -294,7 +295,7 @@ public final class SessionImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultProperties() {
|
private void setDefaultProperties() {
|
||||||
properties.putIfAbsent( AvailableSettings.FLUSH_MODE, getHibernateFlushMode() );
|
properties.putIfAbsent( AvailableSettings.FLUSH_MODE, getHibernateFlushMode().name() );
|
||||||
properties.putIfAbsent( JPA_LOCK_SCOPE, PessimisticLockScope.EXTENDED.name() );
|
properties.putIfAbsent( JPA_LOCK_SCOPE, PessimisticLockScope.EXTENDED.name() );
|
||||||
properties.putIfAbsent( JPA_LOCK_TIMEOUT, LockOptions.WAIT_FOREVER );
|
properties.putIfAbsent( JPA_LOCK_TIMEOUT, LockOptions.WAIT_FOREVER );
|
||||||
properties.putIfAbsent( JPA_SHARED_CACHE_RETRIEVE_MODE, CacheModeHelper.DEFAULT_RETRIEVE_MODE );
|
properties.putIfAbsent( JPA_SHARED_CACHE_RETRIEVE_MODE, CacheModeHelper.DEFAULT_RETRIEVE_MODE );
|
||||||
|
|
|
@ -31,12 +31,10 @@ import org.hibernate.FlushMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.MappingException;
|
|
||||||
import org.hibernate.NonUniqueResultException;
|
import org.hibernate.NonUniqueResultException;
|
||||||
import org.hibernate.PropertyNotFoundException;
|
import org.hibernate.PropertyNotFoundException;
|
||||||
import org.hibernate.ScrollMode;
|
import org.hibernate.ScrollMode;
|
||||||
import org.hibernate.ScrollableResults;
|
import org.hibernate.ScrollableResults;
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.TypeMismatchException;
|
import org.hibernate.TypeMismatchException;
|
||||||
import org.hibernate.engine.query.spi.EntityGraphQueryHint;
|
import org.hibernate.engine.query.spi.EntityGraphQueryHint;
|
||||||
import org.hibernate.engine.query.spi.HQLQueryPlan;
|
import org.hibernate.engine.query.spi.HQLQueryPlan;
|
||||||
|
@ -63,7 +61,6 @@ import org.hibernate.query.QueryParameter;
|
||||||
import org.hibernate.query.spi.QueryImplementor;
|
import org.hibernate.query.spi.QueryImplementor;
|
||||||
import org.hibernate.query.spi.QueryParameterBinding;
|
import org.hibernate.query.spi.QueryParameterBinding;
|
||||||
import org.hibernate.transform.ResultTransformer;
|
import org.hibernate.transform.ResultTransformer;
|
||||||
import org.hibernate.type.SerializableType;
|
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
import static org.hibernate.jpa.QueryHints.HINT_CACHEABLE;
|
import static org.hibernate.jpa.QueryHints.HINT_CACHEABLE;
|
||||||
|
@ -144,7 +141,10 @@ public abstract class AbstractProducedQuery<R> implements QueryImplementor<R> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlushModeType getFlushMode() {
|
public FlushModeType getFlushMode() {
|
||||||
return FlushModeTypeHelper.getFlushModeType( flushMode );
|
return ( flushMode == null ?
|
||||||
|
getProducer().getFlushMode() :
|
||||||
|
FlushModeTypeHelper.getFlushModeType( flushMode )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,12 +26,11 @@ import javax.persistence.Query;
|
||||||
|
|
||||||
import org.hibernate.FlushMode;
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.jpa.AvailableSettings;
|
import org.hibernate.jpa.AvailableSettings;
|
||||||
import org.hibernate.jpa.HibernateEntityManager;
|
|
||||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -221,8 +220,8 @@ public class EntityManagerTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.setFlushMode( FlushModeType.COMMIT );
|
em.setFlushMode( FlushModeType.COMMIT );
|
||||||
assertEquals( FlushModeType.COMMIT, em.getFlushMode() );
|
assertEquals( FlushModeType.COMMIT, em.getFlushMode() );
|
||||||
( ( HibernateEntityManager ) em ).getSession().setFlushMode( FlushMode.ALWAYS );
|
( (Session) em ).setFlushMode( FlushMode.ALWAYS );
|
||||||
assertNull( em.getFlushMode() );
|
assertEquals( em.getFlushMode(), FlushModeType.AUTO );
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue