HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (test fixup)
This commit is contained in:
parent
52fd42ebb4
commit
f826b7d5e8
|
@ -9,6 +9,7 @@ package org.hibernate.userguide.flush;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityTransaction;
|
import javax.persistence.EntityTransaction;
|
||||||
|
import javax.persistence.FlushModeType;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@ -126,6 +127,14 @@ public class AutoFlushTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
entityManager.persist( person );
|
entityManager.persist( person );
|
||||||
Session session = entityManager.unwrap(Session.class);
|
Session session = entityManager.unwrap(Session.class);
|
||||||
|
|
||||||
|
// for this to work, the Session/EntityManager must be put into COMMIT FlushMode
|
||||||
|
// - this is a change since 5.2 to account for merging EntityManager functionality
|
||||||
|
// directly into Session. Flushing would be the JPA-spec compliant behavior,
|
||||||
|
// so we know do that by default.
|
||||||
|
session.setFlushMode( FlushModeType.COMMIT );
|
||||||
|
// or using Hibernate's FlushMode enum
|
||||||
|
//session.setHibernateFlushMode( FlushMode.COMMIT );
|
||||||
|
|
||||||
assertTrue(((Number) session
|
assertTrue(((Number) session
|
||||||
.createSQLQuery( "select count(*) from Person")
|
.createSQLQuery( "select count(*) from Person")
|
||||||
.uniqueResult()).intValue() == 0 );
|
.uniqueResult()).intValue() == 0 );
|
||||||
|
|
|
@ -239,7 +239,11 @@ public class NativeQueryImpl<T> extends AbstractProducedQuery<T> implements Nati
|
||||||
effectiveFlushMode = getProducer().getHibernateFlushMode();
|
effectiveFlushMode = getProducer().getHibernateFlushMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( effectiveFlushMode != FlushMode.MANUAL ) {
|
if ( effectiveFlushMode == FlushMode.ALWAYS ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( effectiveFlushMode == FlushMode.AUTO ) {
|
||||||
if ( getProducer().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
if ( getProducer().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue