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