Package org.hibernate.ogm

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


  }

  @Test
  public void testUniqueResultQuery() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { name:'Portia', author:'Oscar Wilde' } ) RETURN n";
    OscarWildePoem poem = (OscarWildePoem) session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )
        .uniqueResult();
View Full Code Here


  }

  @Test
  public void testListMultipleResultQuery() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " ) RETURN n ORDER BY n.name";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )
View Full Code Here

  }

  @Test
  public void testListMultipleResultQueryWithoutReturnedType() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " ) RETURN n.name, n.author ORDER BY n.name";
    @SuppressWarnings("unchecked")
    List<Object[]> result = session.createNativeQuery( nativeQuery ).list();
View Full Code Here

  }

  @Test
  public void testUniqueResultNamedNativeQuery() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    try {
      OscarWildePoem uniqueResult = (OscarWildePoem) session.getNamedQuery( "AthanasiaQuery" )
          .uniqueResult();
      assertThat( uniqueResult ).isEqualTo( athanasia );
View Full Code Here

  }

  @Test
  public void testUniqueResultFromNativeQueryWithParameter() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    try {
      String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { name:{name}, author:'Oscar Wilde' } ) RETURN n";
      SQLQuery query = session.createNativeQuery( nativeQuery ).addEntity( OscarWildePoem.class );
      query.setParameter( "name", "Portia" );
View Full Code Here

  }

  @Test
  public void testNativeQueryWithFirstResult() throws Exception {
    OgmSession session = (OgmSession) openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { author:'Oscar Wilde' } ) RETURN n ORDER BY n.name";
    Query query = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.class )
        .setFirstResult( 1 );
View Full Code Here

  }

  @Test
  public void testNativeQueryWithMaxRows() throws Exception {
    OgmSession session = (OgmSession) openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { author:'Oscar Wilde' } ) RETURN n ORDER BY n.name";
    Query query = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.class )
        .setMaxResults( 2 );
View Full Code Here

  @Test
  @TestForIssue(jiraKey = "OGM-612")
  public void canUseObjectIdAssignedUponInsertWithEmbeddable() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

    // given
    EntityWithObjectIdAndEmbeddable entity = new EntityWithObjectIdAndEmbeddable();
    AnEmbeddable anEmbeddable = new AnEmbeddable( "a very nice string", null );
    entity.setAnEmbeddable( anEmbeddable );
View Full Code Here

    // when
    session.persist( entity );

    tx.commit();
    session.clear();
    tx = session.beginTransaction();

    EntityWithObjectIdAndEmbeddable loaded = (EntityWithObjectIdAndEmbeddable) session.load( EntityWithObjectIdAndEmbeddable.class, entity.getId() );

    // then
    assertThat( loaded.getId() ).isEqualTo( entity.getId() );
View Full Code Here

  @Test
  @TestForIssue(jiraKey = "OGM-612")
  public void canUseObjectIdAssignedUponInsertWithNestedEmbeddable() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

    // given
    EntityWithObjectIdAndEmbeddable entity = new EntityWithObjectIdAndEmbeddable();
    AnotherEmbeddable anotherEmbeddable = new AnotherEmbeddable( "Another nice string ... nested" );
    AnEmbeddable anEmbeddable = new AnEmbeddable( "a very nice string", anotherEmbeddable );
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.