Package javax.persistence

Examples of javax.persistence.EntityManager.createNamedQuery()


    Mouse mouse = new Mouse();
    mouse.setName( "mickey" );
    em.getTransaction().begin();
    em.persist( as );
    em.persist( mouse );
    assertEquals( 1, em.createNamedQuery( "allMouse" ).getResultList().size() );
    Lighter lighter = new Lighter();
    lighter.name = "main";
    lighter.power = " 250 W";
    em.persist( lighter );
    em.flush();
View Full Code Here


    el.setName( "Dumbo" );
    carpet.setCountry( "Turkey" );
    em.getTransaction().begin();
    em.persist( carpet );
    em.persist( el );
    assertEquals( 1, em.createNamedQuery( "allCarpet" ).getResultList().size() );
    assertNotNull( carpet.getId() );
    em.remove( carpet );
    em.getTransaction().commit();
    em.close();
    emf.close();
View Full Code Here

   public Query createNamedQuery(String name)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNamedQuery(name);
   }

   public Query createNativeQuery(String sqlString)
   {
      EntityManager em = getEntityManager();
View Full Code Here

   public Query createNamedQuery(String name)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNamedQuery(name);
   }

   public Query createNativeQuery(String sqlString)
   {
      EntityManager em = getEntityManager();
View Full Code Here

    @SuppressWarnings("unchecked")
    private List<Long> getProcessInstancesForEvent(String type) {
        EntityManager em = (EntityManager) getWorkingMemory().getEnvironment().get( EnvironmentName.ENTITY_MANAGER );
       
        Query processInstancesForEvent = em.createNamedQuery( "ProcessInstancesWaitingForEvent" );
        processInstancesForEvent.setFlushMode(FlushModeType.COMMIT);
        processInstancesForEvent.setParameter( "type",
                                               type );
        List<Long> list = (List<Long>) processInstancesForEvent.getResultList();
        return list;
View Full Code Here

     * Optimistic=true, but a lock mode specified - assert statement will lock.
     */
    public void testForUpdateClausePresentInNamedQueryWithLockMode() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.getTransaction().begin();
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.close();
View Full Code Here

        em.getTransaction().rollback();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.getTransaction().begin();
        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id", 0));
        em.getTransaction().rollback();
        em.close();
    }

    /*
 
View Full Code Here

     * Optimistic=true, but a no lock mode specified - assert statement does not lock.
     */
    public void testForUpdateClausePresentInQueryWithDefault() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
       
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
        OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id", 0);
        FetchPlan fp = q.getFetchPlan();
View Full Code Here

     */
    public void testForUpdateClausePresentInQueryWithDefault() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id", 0));
       
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
        OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id", 0);
        FetchPlan fp = q.getFetchPlan();
        fp.setReadLockMode(LockModeType.NONE);
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.