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 07:09 Go to next message
James Rawlings is currently offline James Rawlings
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 09: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 10:20 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 995
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: Sun Apr 20 07:02:47 EDT 2014

Powered by FUDForum. Page generated in 0.01885 seconds