Examples of createNativeQuery()


Examples of javax.persistence.EntityManager.createNativeQuery()

    begin();
    EntityManager em = createEntityManager();

    String nativeQuery = "{ $and: [ { name : 'Portia' }, { author : 'Oscar Wilde' } ] }";
    try {
      em.createNativeQuery( nativeQuery ).getSingleResult();
      commit();
    }
    catch (Exception he) {
      rollback();
      String message = he.getMessage();
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  public void testListMultipleResultQuery() throws Exception {
    begin();
    EntityManager em = createEntityManager();
    String nativeQuery = "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> results = em.createNativeQuery( nativeQuery, OscarWildePoem.class ).getResultList();

    assertThat( results ).as( "Unexpected number of results" ).hasSize( 2 );
    assertAreEquals( athanasia, results.get( 0 ) );
    assertAreEquals( portia, results.get( 1 ) );
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  public void testEntitiesInsertedInCurrentSessionAreFoundByNativeQuery() throws Exception {
    begin();
    EntityManager em = createEntityManager();

    String nativeQuery = "{ name : 'Her Voice' }";
    Query query = em.createNativeQuery( nativeQuery, OscarWildePoem.class );

    List<OscarWildePoem> results = query.getResultList();
    assertThat( results ).as( "Unexpected number of results" ).hasSize( 0 );

    OscarWildePoem voice = new OscarWildePoem( 3L, "Her Voice", "Oscar Wilde" );
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  public void testSingleResultQueryUsingExtendedSyntax() throws Exception {
    begin();
    EntityManager em = createEntityManager();
    String nativeQuery = "db.WILDE_POEM.find({ '$query' : { 'name' : 'Athanasia' }, '$orderby' : { 'name' : 1 } })";
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> results = em.createNativeQuery( nativeQuery, OscarWildePoem.class ).getResultList();

    assertThat( results ).as( "Unexpected number of results" ).hasSize( 1 );
    assertAreEquals( athanasia, results.get( 0 ) );

    commit();
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  public Query createNativeQuery(String arg0)
  {
    EntityManager em = getPersistenceContext(false);
    try {
      return em.createNativeQuery(arg0);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  @SuppressWarnings("unchecked")
  public Query createNativeQuery(String arg0, Class arg1)
  {
    EntityManager em = getPersistenceContext(false);
    try {
      return em.createNativeQuery(arg0, arg1);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
View Full Code Here

Examples of javax.persistence.EntityManager.createNativeQuery()

  public Query createNativeQuery(String arg0, String arg1)
  {
    EntityManager em = getPersistenceContext(false);
    try {
      return em.createNativeQuery(arg0, arg1);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.createNativeQuery()

        //q1.setOrdering("intField ascending");
        StateImagePC2 pc1 = (StateImagePC2) ((Collection) q1.getCandidateCollection()).
                iterator().next();
        q1.closeAll();
       
        OpenJPAQuery q2 = pm2.createNativeQuery("",StateImagePC2.class);
        //FIXME jthomas
        //q2.setOrdering("intField ascending");
        StateImagePC2 pc2 = (StateImagePC2) ((Collection) q2.getCandidateCollection()).
                iterator().next();
        q2.closeAll();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.createNativeQuery()

    }

    public void testProjections()
        throws Exception {
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        OpenJPAQuery q = pm.createNativeQuery("",Relations.class);
        //FIXME jthomas
        /*
        q.setResult("base, baseSub1, baseSub1Sub2");
        q.setUnique(true);
        Object[] res = (Object[]) q.execute();
View Full Code Here

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.createNativeQuery()

        super(test);
    }

    public void testQuery() {
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        OpenJPAQuery q = pm.createNativeQuery("",NoClassColumn.class);
        //FIXME jthomas
        //q.declareParameters("java.lang.String input");
        //q.setFilter("test==input");
        Map params = new HashMap();
        params.put("input", "blah");
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.