-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: QueryBuilder Throws AbstractMethodError in JPA
PostPosted: Tue Jun 01, 2010 1:58 pm 
Newbie

Joined: Tue Jun 01, 2010 1:30 pm
Posts: 1
The following exception is thrown when attempting to use JPA to get size of a table (simple count() operation):

Code:
java.lang.AbstractMethodError: org.hibernate.ejb.EntityManagerImpl.getCriteriaBuilder()Ljavax/persistence/criteria/CriteriaBuilder;
        at com.rfm.entities.CustomerJpaController.getCustomerCount(CustomerJpaController.java:162)
        at com.rfm.wicket.HomePage$1.size(HomePage.java:35)
        .....


The Netbeans JPA wizard provided this code for the function:
Code:
public int getCustomerCount() {
        EntityManager em = getEntityManager();
        try {
            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
            Root<Customer> rt = cq.from(Customer.class);
            cq.select(em.getCriteriaBuilder().count(rt));
            Query q = em.createQuery(cq);
            return ((Long) q.getSingleResult()).intValue();
        } finally {
            em.close();
        }
    }

Using Netbeans 6.8, GlassfishV3, latest JavaDB libraries, JDK 1.6.0_13 and internal Netbeans Hibernate JPA libraries
Perhaps someone has seen this before and knows the source of the problem
Thanks


Top
 Profile  
 
 Post subject: Re: QueryBuilder Throws AbstractMethodError in JPA
PostPosted: Sat Jul 24, 2010 6:02 am 
Newbie

Joined: Tue Mar 30, 2010 2:10 pm
Posts: 4
I have the same problem. Did you manage to solve it somehow?

Thanks in advance.. :)

Best regards,
Vasko


Top
 Profile  
 
 Post subject: Re: QueryBuilder Throws AbstractMethodError in JPA
PostPosted: Sat Jul 24, 2010 6:22 am 
Newbie

Joined: Thu Jul 15, 2010 6:44 am
Posts: 13
From the face of it looks like the Entity Manager Impl is not supporting the method ".getCriteriaBuilder()" .

Try changing the hibernate jars to the latest available.

_________________
Vikram.
Http://enterprisejava4u.blogspot.com


Top
 Profile  
 
 Post subject: Re: QueryBuilder Throws AbstractMethodError in JPA
PostPosted: Sat Jul 24, 2010 6:56 am 
Newbie

Joined: Tue Mar 30, 2010 2:10 pm
Posts: 4
Thanks for the point. It turned out that since it was a fresh install of GlassFish it did not have the Hibernate module installed with it (or it had but not updated).. installed (or updated) it and it worked...

Thanks again...

Best regards,
Vasko


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.