Example usage for org.hibernate FlushMode AUTO

List of usage examples for org.hibernate FlushMode AUTO

Introduction

In this page you can find the example usage for org.hibernate FlushMode AUTO.

Prototype

FlushMode AUTO

To view the source code for org.hibernate FlushMode AUTO.

Click Source Link

Document

The Session is sometimes flushed before query execution in order to ensure that queries never return stale state.

Usage

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testSaveOrUpdateWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();

    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.saveOrUpdate("myEntity", tb);
    verify(session).saveOrUpdate("myEntity", tb);
    verify(session).flush();/*from   w w  w . j  a v  a  2  s.c o m*/
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testReplicate() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();/*from w  w  w. j  a v a 2 s .co m*/
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testReplicateWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();//from   w w  w . ja v  a 2 s. c  o m
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testPersist() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.persist(tb);// www. j a v  a  2  s. c om
    verify(session).persist(tb);
    verify(session).flush();
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testPersistWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.persist("myEntity", tb);
    verify(session).persist("myEntity", tb);
    verify(session).flush();/*w  ww.  ja  v  a 2  s.  c  o m*/
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testMerge() throws HibernateException {
    TestBean tb = new TestBean();
    TestBean tbMerged = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    given(session.merge(tb)).willReturn(tbMerged);
    assertSame(tbMerged, hibernateTemplate.merge(tb));
    verify(session).flush();//from  ww  w. jav a2  s .c  om
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testMergeWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    TestBean tbMerged = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    given(session.merge("myEntity", tb)).willReturn(tbMerged);
    assertSame(tbMerged, hibernateTemplate.merge("myEntity", tb));
    verify(session).flush();//  w  ww. j  a v a  2  s.  c om
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testDelete() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.delete(tb);/*  ww w  .  j a v a2s.c o  m*/
    verify(session).delete(tb);
    verify(session).flush();
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testDeleteWithLockMode() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.delete(tb, LockMode.UPGRADE);
    verify(session).lock(tb, LockMode.UPGRADE);
    verify(session).delete(tb);/* w w w.ja va  2s.c  o m*/
    verify(session).flush();
    verify(session).close();
}

From source file:org.springframework.orm.hibernate3.HibernateTemplateTests.java

License:Apache License

@Test
public void testDeleteWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.delete("myEntity", tb);
    verify(session).delete("myEntity", tb);
    verify(session).flush();//from  www . j  a va  2 s  .  c o  m
    verify(session).close();
}