小编Bea*_*ost的帖子

QueryException:"select new"查询不允许使用ResultTransformer

我有以下SpringData存储库查询:

    @Query("SELECT new com.mypackage.MobileCaseList(c.ident, concat(c.subtype, ' - ', c.contactName), c.type, coalesce(c.updateTimestamp,c.insertTimestamp) )" +  
            "FROM MobileCase c WHERE c.mobileUser.ident = ?1 AND c.origin = 'SOURCE' ORDER BY c.appointmentFrom NULLS LAST") 
    List<MobileCaseList> findCasesForUser(String userIdent);
Run Code Online (Sandbox Code Playgroud)

并遵循运行时代码:

    List<MobileCaseList> result = caseRepo.findCasesForUser(userIdent);
Run Code Online (Sandbox Code Playgroud)

到目前为止,这种方法运行良好 - 不知道是什么导致了例外.在我的电脑(localhost)上它仍然有用!?但是在Ubuntu服务器上,查询执行失败并出现以下错误:

2016-02-17 12:56:49.696 ERROR 13397 --- [http-nio-9090-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: ResultTransformer is not allowed for 'select new' queries.; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate jpa hql

11
推荐指数
1
解决办法
1064
查看次数

标签 统计

hibernate ×1

hql ×1

java ×1

jpa ×1

spring ×1