Package org.hibernate.ejb

Examples of org.hibernate.ejb.QueryImpl


                "alertDefinition.resource", subject.getId());
        }

        Query query = generator.getQuery(entityManager);
        if (log.isDebugEnabled()) {
            QueryImpl queryImpl = (QueryImpl) query;
            PageControl pageControl = CriteriaQueryGenerator.getPageControl(criteria);
            log.debug("*Executing JPA query: " + queryImpl.getHibernateQuery().getQueryString() + ", selection=["
                + pageControl.getStartRow() + ".." + (pageControl.getStartRow() + pageControl.getPageSize() - 1)
                + "]...");
        }

        CriteriaQueryRunner<Alert> queryRunner = new CriteriaQueryRunner<Alert>(criteria, generator, entityManager);
View Full Code Here


  }

  public void testOverallLockMode() {
    EntityManager em = getOrCreateEntityManager();
    em.getTransaction().begin();
    QueryImpl jpaQuery = em.createQuery( "from Lockable l" ).unwrap( QueryImpl.class );

    org.hibernate.impl.QueryImpl hqlQuery = (org.hibernate.impl.QueryImpl) jpaQuery.getHibernateQuery();
    assertEquals( LockMode.NONE, hqlQuery.getLockOptions().getLockMode() );
    assertNull( hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
    assertEquals( LockMode.NONE, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );

    // NOTE : LockModeType.READ should map to LockMode.OPTIMISTIC
    jpaQuery.setLockMode( LockModeType.READ );
    assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getLockMode() );
    assertNull( hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
    assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );

    jpaQuery.setHint( AvailableSettings.ALIAS_SPECIFIC_LOCK_MODE+".l", LockModeType.PESSIMISTIC_WRITE );
    assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getLockMode() );
    assertEquals( LockMode.PESSIMISTIC_WRITE, hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
    assertEquals( LockMode.PESSIMISTIC_WRITE, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );

    em.getTransaction().commit();
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.QueryImpl

Copyright © 2018 www.massapicom. 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.