Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA 2 Query casting throwing exception(JPA Criteria API)
JPA 2 Query casting throwing exception [message #644286] Fri, 10 December 2010 12:09 Go to next message
James Rawlings is currently offline James RawlingsFriend
Messages: 2
Registered: December 2010
Junior Member
Follwing the example from http:// wiki.eclipse.org/EclipseLink/Release/2.1.0/JPAQueryEnhanceme nts I am casting the query to a subclass using the criteria API Expression.as(type). When casting the result to a Path as per the the example I get a class cast exception.

Root<Employee> empRoot = cq1.from(getEntityManagerFactory().getMetamodel().entity(Employee.class));
Join<Employee, Project> join = empRoot.join("projects");
Path exp = ((Path)join.as(LargeProject.class)).get("budget");


exception thrown..

ClassCastException: Cannot cast org.hibernate.ejb.criteria.expression.function.CastFunction (id=113) to java.persistence.criteria.Path

Can anybody help? Many thanks.

[Updated on: Fri, 10 December 2010 14:26]

Report message to a moderator

Re: JPA 2 Query casting throwing exception [message #644334 is a reply to message #644286] Fri, 10 December 2010 15:20 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

The error states you are using Hibernate as your JPA provider.
You need to use EclipseLink as the provider to get EclipseLink features. ie
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
in your persistence.xml with the EclipseLink jar on your classpath. see
http://wiki.eclipse.org/EclipseLink/Examples

Regards,
Chris
Previous Topic:BigDecimal correctly persisted but not correctly loaded
Next Topic:TableGenerator Sequencing options
Goto Forum:
  


Current Time: Mon Nov 24 15:32:46 GMT 2014

Powered by FUDForum. Page generated in 0.14804 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software