Package org.hibernate.ogm

Examples of org.hibernate.ogm.OgmSession.clear()


    // when
    session.persist( gloria );

    tx.commit();
    assertThat( gloria.getId() ).isNotNull();
    session.clear();
    tx = session.beginTransaction();

    Singer singerLoaded = (Singer) session.load( Singer.class, gloria.getId() );

    // then
View Full Code Here


    // when
    session.persist( monty );

    tx.commit();
    assertThat( monty.getId() ).isNotNull();
    session.clear();
    tx = session.beginTransaction();

    // then
    assertCountQueryResult( session, "db.Comedian.count({ \"_id\" : { \"$oid\" : \"" + monty.getId() + "\" }, \"name\" : \"Monty\" })", 1L);
View Full Code Here

    List<OscarWildePoem> result = query.list();

    assertThat( result ).onProperty( "id" ).containsExactly( 3L, 1L );

    transaction.commit();
    session.clear();
    session.close();
  }

  @Test
  public void testNativeQueryWithMaxRows() throws Exception {
View Full Code Here

    List<OscarWildePoem> result = query.list();

    assertThat( result ).onProperty( "id" ).containsExactly( 2L, 3L );

    transaction.commit();
    session.clear();
    session.close();
  }

  @Test
  public void testListMultipleResultQuery() throws Exception {
View Full Code Here

        .list();

    assertThat( result ).onProperty( "id" ).containsExactly( 2L, 3L, 1L );

    transaction.commit();
    session.clear();
    session.close();
  }

  @Test
  public void testListMultipleResultQueryWithFirstResultAndMaxRows() throws Exception {
View Full Code Here

        .list();

    assertThat( result ).onProperty( "id" ).containsExactly( 3L );

    transaction.commit();
    session.clear();
    session.close();
  }

  @Test
  public void testExceptionWhenReturnedEntityIsMissingAndUniqueResultIsExpected() throws Exception {
View Full Code Here

      assertThat( message )
        .as( "The native query doesn't define a returned entity, there should be a specific exception" )
        .contains( "OGM001217" );
    }
    finally {
      session.clear();
      session.close();
    }
  }

  @Test
View Full Code Here

      assertThat( message )
        .as( "The native query doesn't define a returned entity, there should be a specific exception" )
        .contains( "OGM001217" );
    }
    finally {
      session.clear();
      session.close();
    }
  }

  private void assertAreEquals(OscarWildePoem expectedPoem, OscarWildePoem poem) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.