本文整理了Java中javax.persistence.Query.setFlushMode
方法的一些代码示例,展示了Query.setFlushMode
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFlushMode
方法的具体详情如下:
包路径:javax.persistence.Query
类名称:Query
方法名:setFlushMode
[英]Set the flush mode type to be used for the query execution. The flush mode type applies to the query regardless of the flush mode type in use for the entity manager.
[中]设置用于查询执行的刷新模式类型。刷新模式类型应用于查询,而与实体管理器使用的刷新模式类型无关。
代码示例来源:origin: kiegroup/jbpm
query.setFlushMode(FlushModeType.valueOf((String) params.get(name)));
continue;
代码示例来源:origin: kiegroup/jbpm
query.setFlushMode(FlushModeType.valueOf((String) paramEntry.getValue()));
continue;
代码示例来源:origin: spring-projects/spring-framework
@Test
@SuppressWarnings("unchecked")
public void testQueryNoPersonsShared() {
Query q = this.sharedEntityManager.createQuery("select p from Person as p");
q.setFlushMode(FlushModeType.AUTO);
List<Person> people = q.getResultList();
assertEquals(0, people.size());
try {
assertNull(q.getSingleResult());
fail("Should have thrown NoResultException");
}
catch (NoResultException ex) {
// expected
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testFlushJPQL() {
doInJPA( this::entityManagerFactory, entityManager -> {
log.info("testFlushJPQL");
//tag::flushing-commit-flush-jpql-example[]
Person person = new Person("John Doe");
entityManager.persist(person);
entityManager.createQuery("select p from Advertisement p")
.setFlushMode( FlushModeType.COMMIT)
.getResultList();
entityManager.createQuery("select p from Person p")
.setFlushMode( FlushModeType.COMMIT)
.getResultList();
//end::flushing-commit-flush-jpql-example[]
});
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@SuppressWarnings("unchecked")
public void testQueryNoPersonsSharedNotTransactional() {
endTransaction();
EntityManager em = this.sharedEntityManager;
Query q = em.createQuery("select p from Person as p");
q.setFlushMode(FlushModeType.AUTO);
List<Person> people = q.getResultList();
assertEquals(0, people.size());
try {
assertNull(q.getSingleResult());
fail("Should have thrown IllegalStateException");
}
catch (Exception ex) {
// We would typically expect an IllegalStateException, but Hibernate throws a
// PersistenceException. So we assert the contents of the exception message instead.
assertTrue(ex.getMessage().contains("closed"));
}
q = em.createQuery("select p from Person as p");
q.setFlushMode(FlushModeType.AUTO);
try {
assertNull(q.getSingleResult());
fail("Should have thrown NoResultException");
}
catch (NoResultException ex) {
// expected
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void test_jpql_api_basic_usage_example() {
doInJPA( this::entityManagerFactory, entityManager -> {
//tag::jpql-api-basic-usage-example[]
Query query = entityManager.createQuery(
"select p " +
"from Person p " +
"where p.name like :name" )
// timeout - in milliseconds
.setHint( "javax.persistence.query.timeout", 2000 )
// flush only at commit time
.setFlushMode( FlushModeType.COMMIT );
//end::jpql-api-basic-usage-example[]
});
}
代码示例来源:origin: Impetus/Kundera
@Override
public TypedQuery<X> setFlushMode(FlushModeType arg0)
{
query.setFlushMode(arg0);
return this;
}
代码示例来源:origin: org.apache.openejb/openejb-core
@Override
public Query apply(final Query query) {
return query.setFlushMode(flushModeType);
}
});
代码示例来源:origin: Blazebit/blaze-persistence
@Override
public Query postProcess(EntityViewCdiQueryInvocationContext context, Query query) {
query.setFlushMode(flushMode);
return query;
}
}
代码示例来源:origin: kumuluz/kumuluzee
@Override
public Query setFlushMode(FlushModeType flushMode) {
query.setFlushMode(flushMode);
return this;
}
代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7
@Override
public Query postProcess(EntityViewCdiQueryInvocationContext context, Query query) {
query.setFlushMode(flushMode);
return query;
}
}
代码示例来源:origin: org.jboss.eap/wildfly-jpa
@Override
public Query setFlushMode(FlushModeType flushMode) {
underlyingQuery.setFlushMode(flushMode);
return this;
}
代码示例来源:origin: Blazebit/blaze-persistence
@Override
public Query setFlushMode(FlushModeType flushMode) {
delegate.setFlushMode(flushMode);
return this;
}
代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl
@Override
public Query postProcess(EntityViewCdiQueryInvocationContext context, Query query) {
query.setFlushMode(flushMode);
return query;
}
}
代码示例来源:origin: org.evolvis.bsi/kolab-ws
@Override
public Query
setFlushMode(FlushModeType flushMode)
{
return delegate.setFlushMode(flushMode);
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public Query apply(final Query query) {
return query.setFlushMode(flushModeType);
}
});
代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-data-module-impl
@Override
public Query postProcess(CdiQueryInvocationContext context, Query query)
{
query.setFlushMode(flushMode);
return query;
}
代码示例来源:origin: org.apache.openejb/openejb-core
public Query setFlushMode(final FlushModeType flushModeType) {
query.setFlushMode(flushModeType);
if (!underTx) {
appliedOperations.add(new QueryOperation() {
@Override
public Query apply(final Query query) {
return query.setFlushMode(flushModeType);
}
});
}
return this;
}
代码示例来源:origin: org.apache.tomee/openejb-core
public Query setFlushMode(final FlushModeType flushModeType) {
query.setFlushMode(flushModeType);
if (!underTx) {
appliedOperations.add(new QueryOperation() {
@Override
public Query apply(final Query query) {
return query.setFlushMode(flushModeType);
}
});
}
return this;
}
代码示例来源:origin: org.actframework/act-jpa-common
@Override
public Query setFlushMode(FlushModeType flushMode) {
this.flushMode = $.requireNotNull(flushMode);
if (null != q) {
q.setFlushMode(flushMode);
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!