Skip to content

Commit

Permalink
OGM-1407 Additional test cases for positional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD committed Apr 20, 2018
1 parent 669d92b commit e710d5c
Showing 1 changed file with 27 additions and 0 deletions.
Expand Up @@ -199,6 +199,33 @@ public void testQueryWithPositionalParams() {
em.getTransaction().commit();
}

@Test
public void testQueryWithAlternativePositionalParams() {
em.getTransaction().begin();

String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { name: {34}, author: {35}} ) RETURN n";
Query query = em.createNativeQuery( nativeQuery, OscarWildePoem.class );
query.setParameter( 34, "Portia" );
query.setParameter( 35, "Oscar Wilde" );
OscarWildePoem result = (OscarWildePoem) query.getSingleResult();
assertAreEquals( portia, result );

em.getTransaction().commit();
}

@Test
public void testQueryWithDuplicatedPositionalParams() {
em.getTransaction().begin();

String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { name: {5}, author: {5}} ) RETURN n";
Query query = em.createNativeQuery( nativeQuery, OscarWildePoem.class );
query.setParameter( 5, "Portia" );
List<?> result = query.getResultList();
assertThat( result ).isEmpty();

em.getTransaction().commit();
}

private void persist(Object... entities) {
EntityManager em = createEntityManager();
em.getTransaction().begin();
Expand Down

0 comments on commit e710d5c

Please sign in to comment.