-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPA 2.0 Criteria API with MetaModel Not working
PostPosted: Tue Mar 30, 2010 11:05 pm 
Newbie

Joined: Tue Mar 30, 2010 11:01 pm
Posts: 2
Hello,

I am trying to get below code snippet working. I am using JPA 2.0 with Spring 3.0.1. I have create MetaModel class Employee_. I get NullPointerException when control reach at Employee_.fName.

I tried defining Employee_ class in persistence.xml file same like how we define there entities.

Am I missing something?

Thanks,
Mahesh

Code:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery criteria = cb.createQuery(Employee.class);
Root<Employee> entity = criteria.from(Employee.class);
       
criteria.orderBy(cb.asc(entity.get(Employee_.fName)), cb.asc(entity.get(Employee_.lName)));

Query query = em.createQuery(criteria);






Top
 Profile  
 
 Post subject: Re: JPA 2.0 Criteria API with MetaModel Not working
PostPosted: Wed Mar 31, 2010 10:52 pm 
Newbie

Joined: Tue Mar 30, 2010 11:01 pm
Posts: 2
This issue has been resolved.

I kept the Employee_.java metamodel class in the same package where entities are placed.

Thanks,
Mahesh


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