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.hibernate4.HibernateTemplateTests.java

License:Apache License

@Test
public void testSaveWithEntityName() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    given(session.save("myEntity", tb)).willReturn(0);
    assertEquals("Correct return value", hibernateTemplate.save("myEntity", tb), 0);
}

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

License:Apache License

@Test
public void testUpdate() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.update(tb);/*ww w .  j  a  va 2s.  c  o  m*/
    verify(session).update(tb);
}

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

License:Apache License

@Test
public void testUpdateWithEntityName() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.update("myEntity", tb);
    verify(session).update("myEntity", tb);
}

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

License:Apache License

@Test
public void testSaveOrUpdate() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.saveOrUpdate(tb);//from  w  w w.ja v  a  2s  .  c o  m
    verify(session).saveOrUpdate(tb);
}

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

License:Apache License

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

    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.saveOrUpdate("myEntity", tb);
    verify(session).saveOrUpdate("myEntity", tb);
}

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

License:Apache License

@Test
public void testReplicate() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate(tb, ReplicationMode.LATEST_VERSION);
}

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

License:Apache License

@Test
public void testReplicateWithEntityName() {
    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);
}

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

License:Apache License

@Test
public void testPersist() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.persist(tb);/*  w  ww.jav a 2 s .  c o  m*/
    verify(session).persist(tb);
}

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

License:Apache License

@Test
public void testPersistWithEntityName() {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.persist("myEntity", tb);
    verify(session).persist("myEntity", tb);
}

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

License:Apache License

@Test
public void testMerge() {
    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));
}