我试图在Spring 3.0 ORM中使用JPA 2.0. JPA供应商是Hibernate 3.5.0-Beta-3.
它适用于JPQL,但是当我尝试使用CriteriaQuery时,会发生异常:
java.lang.ClassCastException: $Proxy50
cannot be cast to
javax.persistence.TypedQuery at
$Proxy38.createQuery(Unknown Source)
at
com.absorbx.retailx.dao.impl.ShopDaoImpl.findByCrieria(ShopDaoImpl.java:30)
at
com.absorbx.retailx.dao.SimpleDaoTest.testFindByCriteria(SimpleDaoTest.java:39)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
@Repository
public class ShopDaoImpl implements
ShopDao {
@PersistenceContext
transient EntityManager entityManager;
@Override
public Shop findByCrieria() {
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery
我该如何解决这个问题?
最佳答案
它似乎是Spring中的一个错误:
原文链接:https://www.f2er.com/spring/431409.html组织/ springframework的/ ORM / JPA / SharedEntityManagerCreator.java:
if (result instanceof Query) {
Query query = (Query) result;
...
result = Proxy.newProxyInstance(Query.class.getClassLoader(),new Class[] {Query.class},new DeferredQueryInvocationHandler(query,target));
...
}
最好是创建一个问题.