Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with JPA Criteria
PostPosted: Sat Aug 04, 2012 12:15 pm 
Newbie

Joined: Sat Aug 04, 2012 12:00 pm
Posts: 6
Hello, I have the code bellow:
Code:
      CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
      CriteriaQuery<Dog> criteriaQuery = criteriaBuilder.createQuery(Dog.class);
      Root<Dog> mainRoot = criteriaQuery.from(Dog.class);
      criteriaQuery.select(mainRoot);
      criteriaQuery.where(criteriaBuilder.le(mainRoot.get("hairSize").as(Long.class), 10L));
      
      TypedQuery<Dog> query = em.createQuery(criteriaQuery);
      
      System.out.println(query.getResultList().size()); // result is 9
      System.out.println(em.createQuery("select d from Dog d where d.hairSize <= 10L").getResultList().size()); // result is 8

Why is the result not equal?
Am I doing something wrong?

I CANNOT use the Hibernate Criteria or Canonical MetaModel but I must use the JPA Criteria.

My Libraries are:
    antlr-2.7.6.jar
    asm-3.0.jar
    asm-tree-3.0.jar
    cglib-2.2.2.jar
    commons-collections-3.1.jar
    commons-lang3-3.1.jar
    dom4j-1.6.1.jar
    hibernate-commons-annotations-4.0.1.Final.jar
    hibernate-core-4.1.4.Final.jar
    hibernate-entitymanager-4.1.4.Final.jar
    hsqldb.jar
    jakarta-oro-2.0.8.jar
    javassist-3.12.0.GA.jar
    javax.persistence_2.0.0.jar
    jboss-logging-3.1.0.GA.jar
    jboss-transaction-api_1.1_spec-1.0.0.Final.jar
    log4j-1.2.16.jar
    slf4j-api-1.6.1.jar
    slf4j-log4j12-1.6.1.jar

Thanks


Top
 Profile  
 
 Post subject: Re: Problem with JPA Criteria
PostPosted: Tue Aug 07, 2012 11:20 pm 
Newbie

Joined: Sat Aug 04, 2012 12:00 pm
Posts: 6
Any one?

Should it be filled as a bug? =/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.