List of usage examples for org.hibernate FlushMode AUTO
FlushMode AUTO
To view the source code for org.hibernate FlushMode AUTO.
Click Source Link
From source file:org.grails.orm.hibernate4.support.GrailsOpenSessionInViewInterceptor.java
License:Apache License
public void setFlushMode(int flushMode) { if (AbstractHibernateDatastore.FlushMode.AUTO.getLevel() == flushMode) { this.flushMode = AbstractHibernateDatastore.FlushMode.AUTO; } else if (AbstractHibernateDatastore.FlushMode.MANUAL.getLevel() == flushMode) { this.flushMode = AbstractHibernateDatastore.FlushMode.MANUAL; } else if (AbstractHibernateDatastore.FlushMode.COMMIT.getLevel() == flushMode) { this.flushMode = AbstractHibernateDatastore.FlushMode.COMMIT; } else if (AbstractHibernateDatastore.FlushMode.ALWAYS.getLevel() == flushMode) { this.flushMode = AbstractHibernateDatastore.FlushMode.ALWAYS; }/* w ww. ja v a 2s .c o m*/ }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
public int deleteContacts() throws Exception { String deleteHQL = "delete Contact where customer in " + " (select customer FROM Customer as customer where customer.name = :cName)"; int rowsAffected = withTxSessionApply(s -> s.createQuery(deleteHQL).setFlushMode(FlushMode.AUTO) .setParameter("cName", "Red Hat").executeUpdate()); return rowsAffected; }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
@SuppressWarnings({ "unchecked" }) public List<Integer> getContactsByCustomer(String customerName) throws Exception { String selectHQL = "select contact.id from Contact contact" + " where contact.customer.name = :cName"; return (List<Integer>) withTxSessionApply(s -> s.createQuery(selectHQL).setFlushMode(FlushMode.AUTO) .setParameter("cName", customerName).list()); }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
@SuppressWarnings({ "unchecked" }) public List<Integer> getContactsByTLF(String tlf) throws Exception { String selectHQL = "select contact.id from Contact contact" + " where contact.tlf = :cTLF"; return (List<Integer>) withTxSessionApply( s -> s.createQuery(selectHQL).setFlushMode(FlushMode.AUTO).setParameter("cTLF", tlf).list()); }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
public int updateContacts(String name, String newTLF) throws Exception { String updateHQL = "update Contact set tlf = :cNewTLF where name = :cName"; return withTxSessionApply(s -> s.createQuery(updateHQL).setFlushMode(FlushMode.AUTO) .setParameter("cNewTLF", newTLF).setParameter("cName", name).executeUpdate()); }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
public int updateContactsWithOneManual(String name, String newTLF) throws Exception { String queryHQL = "from Contact c where c.name = :cName"; String updateHQL = "update Contact set tlf = :cNewTLF where name = :cName"; return withTxSessionApply(s -> { List<Contact> list = s.createQuery(queryHQL).setParameter("cName", name).list(); list.get(0).setTlf(newTLF);// w w w . j a v a2 s .c o m return s.createQuery(updateHQL).setFlushMode(FlushMode.AUTO).setParameter("cNewTLF", newTLF) .setParameter("cName", name).executeUpdate(); }); }
From source file:org.infinispan.test.hibernate.cache.functional.BulkOperationsTest.java
License:LGPL
public void cleanup(boolean ignore) throws Exception { String deleteContactHQL = "delete from Contact"; String deleteCustomerHQL = "delete from Customer"; withTxSession(s -> {/*ww w .j a v a2s .c o m*/ s.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); s.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); }); }
From source file:org.infinispan.test.hibernate.cache.functional.ConcurrentWriteTest.java
License:LGPL
public void cleanup() throws Exception { getCustomerIDs().clear();//from w w w. ja va 2s. co m String deleteContactHQL = "delete from Contact"; String deleteCustomerHQL = "delete from Customer"; withTxSession(s -> { s.createQuery(deleteContactHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); s.createQuery(deleteCustomerHQL).setFlushMode(FlushMode.AUTO).executeUpdate(); }); }
From source file:org.jboss.as.test.compat.jpa.hibernate.transformer.AbstractVerifyHibernate51CompatibilityTestCase.java
License:Open Source License
@Test public void testORA5_3_1_Compatibility_getFlushModeFromSessionUninitialized() { // setup Configuration and SessionFactory sfsb.setupConfig();//ww w . ja va2 s .c o m try { // Session#getFlushMode returns FlushMode.AUTO by default assertEquals("can handle Hibernate ORM 5.1 call to Session.getFlushMode() without setting FlushMode", FlushMode.AUTO, sfsb.getFlushModeFromSessionTest(null)); } finally { sfsb.cleanup(); } }
From source file:org.jboss.seam.persistence.hibernate.HibernateManagedSessionProxyHandler.java
License:Open Source License
private void changeFushMode(FlushModeType flushModeType) { switch (flushModeType) { case AUTO://from w w w.j ava2s. c o m delegate.setFlushMode(FlushMode.AUTO); break; case MANUAL: delegate.setFlushMode(FlushMode.MANUAL); break; case COMMIT: delegate.setFlushMode(FlushMode.COMMIT); break; default: throw new RuntimeException("Unkown flush mode: " + flushModeType); } }