Examples of createNativeQuery()


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

    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 )
        .list();

    assertThat( result ).as( "Unexpected number of results" ).containsExactly( athanasia, ballade, portia );
View Full Code Here

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

    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();

    assertThat( result ).as( "Unexpected number of results" ).hasSize( 3 );

    Object[] athanasiaRow = result.get( 0 );
    assertThat( athanasiaRow[0] ).isEqualTo( athanasia.getName() );
View Full Code Here

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

    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" );

      OscarWildePoem uniqueResult = (OscarWildePoem) query.uniqueResult();
      assertThat( uniqueResult ).isEqualTo( portia );
      transaction.commit();
View Full Code Here

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

  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 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();
View Full Code Here

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

  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 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();
View Full Code Here

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

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

    Query query = session.createNativeQuery( "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }" )
        .addEntity( OscarWildePoem.class )
        .setFirstResult( 1 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();
View Full Code Here

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

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

    Query query = session.createNativeQuery( "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }" )
        .addEntity( OscarWildePoem.class )
        .setMaxResults( 2 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();
View Full Code Here

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

    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )
        .list();

    assertThat( result ).onProperty( "id" ).containsExactly( 2L, 3L, 1L );
View Full Code Here

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

    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )
        .setFirstResult( 1 )
        .setMaxResults( 1 )
        .list();
View Full Code Here

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

    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    String nativeQuery = "{ $and: [ { name : 'Portia' }, { author : 'Oscar Wilde' } ] }";
    try {
      session.createNativeQuery( nativeQuery ).uniqueResult();
      transaction.commit();
    }
    catch (Exception he) {
      transaction.rollback();
      String message = he.getMessage();
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.