Java Code Examples for javax.persistence.Query#setFlushMode()
The following examples show how to use
javax.persistence.Query#setFlushMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractContainerEntityManagerFactoryIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@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 } }
Example 2
Source File: AbstractContainerEntityManagerFactoryIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@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 } }
Example 3
Source File: AbstractContainerEntityManagerFactoryIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unused", "unchecked" }) public void testQueryNoPersonsShared() { EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory); Query q = em.createQuery("select p from Person as p"); q.setFlushMode(FlushModeType.AUTO); List<Person> people = q.getResultList(); try { assertNull(q.getSingleResult()); fail("Should have thrown NoResultException"); } catch (NoResultException ex) { // expected } }
Example 4
Source File: FlushModePostProcessor.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public Query postProcess(CdiQueryInvocationContext context, Query query) { query.setFlushMode(flushMode); return query; }