2014-10-26 02:12:00,013 DEBUG [ExceptionsHandler] org.springframework.dao.InvalidDataAccessApiUsageException: Undeclared path 'rolloutAdmin'. Add this path as a source to the query to be able to reference it.; nested exception is java.lang.IllegalArgumentException: Undeclared path 'rolloutAdmin'. Add this path as a source to the query to be able to reference it.
@Query("SELECT new com.nsn.nitro.project.data.jpa.domain.RolloutMeta(r, count(b.id) as btsNbAll, ifnull(sum(b.status = com.nsn.nitro.project.data.utils.BTSStatus.PLANNED), 0) as btsNbPlanned, ifnull(sum(b.status = com.nsn.nitro.project.data.utils.BTSStatus.COMPLETED), 0) as btsNbCompleted, ifnull(sum(b.status = com.nsn.nitro.project.data.utils.BTSStatus.COMPLETED), 0) * 100.0 / count(b.id) as btsNbPercentage) FROM Rollout r, RolloutAdmin ra, BTS b WHERE b.rollout.id = r.id AND r.id = ra.rollout.id AND ra.admin = :admin GROUP BY r.id")
public Page<RolloutMeta> findMetaByAdmin(@Param("admin") Admin admin, Pageable page);
@Override
@Transactional(readOnly = true)
public Page<RolloutMeta> findMetaByAdmin(Admin admin, Pageable page) {
JPAQuery query = new JPAQuery(rolloutRepository.getEntityManager());
QRollout qRollout = QRollout.rollout;
QRolloutAdmin qRolloutAdmin = QRolloutAdmin.rolloutAdmin;
QAdmin qAdmin = QAdmin.admin;
QBTS qBTS = QBTS.bTS;
query.from(qRollout).innerJoin(qRolloutAdmin.rollout, qRollout).innerJoin(qRolloutAdmin.admin, qAdmin).innerJoin(qBTS.rollout, qRollout);
BooleanBuilder builder = new BooleanBuilder();
builder.and(qAdmin.eq(admin));
query.where(builder)
NumberExpression<Integer> statusPlanned = qBTS.status.when(com.nsn.nitro.project.data.utils.BTSStatus.PLANNED).then(new Integer(1)).otherwise(new Integer(0));
NumberExpression<Integer> statusCompleted = qBTS.status.when(com.nsn.nitro.project.data.utils.BTSStatus.COMPLETED).then(new Integer(1)).otherwise(new Integer(0));
NumberExpression<Integer> btsNbPlanned = statusPlanned.sum();
NumberExpression<Integer> btsNbCompleted = statusCompleted.sum();
NumberExpression<Integer> btsPercentage = statusCompleted.sum().divide(new Integer(100)).multiply(qBTS.count());
query.orderBy(btsPercentage.desc());
QRolloutMeta qRolloutMeta = new QRolloutMeta(qRollout, qBTS.count(), btsNbPlanned, btsNbCompleted, btsPercentage);
List<RolloutMeta> resultList = query.list(qRolloutMeta);
long total = resultList.size();
query.offset(page.getOffset());
query.limit(page.getPageSize());
resultList = query.list(qRolloutMeta);
Page<RolloutMeta> rolloutMetas = new PageImpl<RolloutMeta>(resultList, page, total);
return rolloutMetas;
}
然后,我尝试将qRolloutAdmin放在query.from(qRolloutAdmin)中,如下所示:
query.from(qRolloutAdmin).innerJoin(qRolloutAdmin.rollout, qRollout).innerJoin(qRolloutAdmin.admin, qAdmin).innerJoin(qBTS.rollout, qRollout);
它似乎改善了一点,这一次的例外情况几乎相同,但在bts一号上:
2014-10-26 08:51:18,489 DEBUG [ExceptionsHandler] org.springframework.dao.InvalidDataAccessApiUsageException: Undeclared path 'bTS'. Add this path as a source to the query to be able to reference it.; nested exception is java.lang.IllegalArgumentException: Undeclared path 'bTS'. Add this path as a source to the query to be able to reference it.
因此,我删除了bts上的内部连接,以便将其放在构建器中:
query.from(qRolloutAdmin).innerJoin(qRolloutAdmin.rollout, qRollout).innerJoin(qRolloutAdmin.admin, qAdmin);
BooleanBuilder builder = new BooleanBuilder();
builder.and(qBTS.rollout.eq(qRollout)).and(qAdmin.eq(admin));
query.where(builder);
2014-10-26 09:08:00,397 DEBUG [ExceptionsHandler] org.springframework.dao.InvalidDataAccessApiUsageException: Undeclared path 'bTS'. Add this path as a source to the query to be able to reference it.; nested exception is java.lang.IllegalArgumentException: Undeclared path 'bTS'. Add this path as a source to the query to be able to reference it.
1- Does the entity sitting in the from method have to be a child one ?
2- Is there any difference between doing an innerJoin and an equal in the builder ?
query.from(qRollout);
query.innerJoin(qRollout, qRolloutAdmin.rollout);
query.innerJoin(qRolloutAdmin.admin, qAdmin);
query.innerJoin(qRollout, qBTS.rollout);
2014-10-26 10:02:04,354 DEBUG [ExceptionsHandler] org.springframework.dao.InvalidDataAccessApiUsageException: rolloutAdmin.rollout is not a root path; nested exception is java.lang.IllegalArgumentException: rolloutAdmin.rollout is not a root path
query.from(qRollout, qRolloutAdmin, qBTS);
但例外情况保持不变。
Edit2:我尝试用一个on()方法指定innerJoin,如2.1.8中所述。参考文档的一般用法部分:
query.from(qRollout);
query.innerJoin(qRolloutAdmin).on(qRolloutAdmin.rollout.eq(qRollout));
query.innerJoin(qRolloutAdmin).on(qRolloutAdmin.admin.eq(qAdmin));
query.innerJoin(qRollout).on(qBTS.rollout.eq(qRollout));
并得到了异常:
2014-10-26 10:24:11,098 DEBUG [ExceptionsHandler] org.springframework.dao.InvalidDataAccessApiUsageException: rolloutAdmin is already used; nested exception is java.lang.IllegalStateException: rolloutAdmin is already used
QRolloutAdmin qRolloutAdmin = QRolloutAdmin.rolloutAdmin;
QRollout qRollout = QRollout.rollout;
QAdmin qAdmin = QAdmin.admin;
QBTS qBTS = QBTS.bTS;
query.from(qRollout);
query.innerJoin(qRolloutAdmin.rollout).on(qRolloutAdmin.rollout.eq(qRollout));
query.innerJoin(qRolloutAdmin.admin).on(qRolloutAdmin.admin.eq(qAdmin));
query.innerJoin(qBTS.rollout).on(qBTS.rollout.eq(qRollout));
Caused by: java.lang.IllegalArgumentException: Undeclared path 'rolloutAdmin'. Add this path as a source to the query to be able to reference it.
query.from(qRollout, qRolloutAdmin, qAdmin, qBTS);
query.innerJoin(qRolloutAdmin.rollout).on(qRolloutAdmin.rollout.eq(qRollout));
query.innerJoin(qRolloutAdmin.admin).on(qRolloutAdmin.admin.eq(qAdmin));
query.innerJoin(qBTS.rollout).on(qBTS.rollout.eq(qRollout));
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.InvalidWithClauseException: with clause can only reference columns in the driving table [select rollout, count(bTS), sum(case when bTS.status = ?1 then ?2 else ?3 end), sum(case when bTS.status = ?4 then ?2 else ?3 end), (sum(case when bTS.status = ?4 then ?2 else ?3 end) / ?5) * count(bTS)
from com.nsn.nitro.project.data.jpa.domain.Rollout rollout, com.nsn.nitro.project.data.jpa.domain.RolloutAdmin rolloutAdmin, com.nsn.nitro.project.data.jpa.domain.Admin admin, com.nsn.nitro.project.data.jpa.domain.BTS bTS
builder.and(qRolloutAdmin.rollout.id.eq(qRollout.id)).and(qRolloutAdmin.admin.id.eq(qAdmin.id)).and(qBTS.rollout.id.eq(qRollout.id));
QueryDSL无法确定搜索的case语句的数据类型
JPA查询中的联接比SQL联接更多的是关于属性遍历。因此,您需要重写查询,以确保所有路径都通过属性连接到根变量。
如果您想从RolloutAdmin开始,那么
query.from(qRolloutAdmin)
.innerJoin(qRolloutAdmin.rollout, qRollout)
.innerJoin(qRolloutAdmin.admin, qAdmin);
现在可以在查询中使用qrolloutadmin
、qrollout
和qadmin
。QBTS
尚未连接到属性树。
问题内容: 我包括以下标题: 我也尝试使用 之前,但这也无济于事。 我尝试使用并将其作为第二个参数传递,但我不断收到此错误消息: 错误:未声明“ F_SETPIPE_SZ”(此函数中的首次使用) 我实际上发现我不需要它,但是我很好奇为什么我不能使用它。 谢谢。 因此,感谢Chrono Kitsune,这是解决方案: 在任何包含之前。 问题答案: 因此,有了Chrono Kitsune,这就是解决方
问题内容: 何时使用语句而不是准备语句。我想在没有参数的查询中使用语句,但是为什么不使用预处理语句呢?对于没有参数的查询,哪一个更快。 问题答案: 我想在没有参数的查询中使用语句,但是为什么不使用预处理语句呢? 还差得远 对于返回结果集或更新计数的INSERT,UPDATE和DELETE语句,使用PreparedStatement。正如Joachim所指出的,它们不适用于DDL语句,也不适用于应使
问题内容: Xcode 8 beta 4不再识别Foundation类。 我在一个简单的操场示例中复制了它: 由于在较早的Xcode 8 Swift 3 Beta中可用,我想这是一个需要修复的错误,而不是Playground中的某些源代码错误? 问题答案: 尽管未在Xcode发行说明中记录,但Swift Foundation中对Swift进化建议SE-0086 Drop NS Prefix 的第2
我弄糊涂了,我出现了一个错误,为什么我的路由过程不起作用,这个错误给我的路由[index]没有定义,但另一方面,我已经定义了HomeController的索引,看看我做的过程, 注意:我使用了laravel版本:5.8* 我创造index.blade.php 将路由添加到web.php,我使用此代码 Web.php 主页控制器 我的网址: 错误:
我使用Visual StudioXML工具创建了XSD。我使用下面的C#代码来验证XML并面对这个错误。 错误 元素没有声明为“http://www.w3.org/2000/09/XMLDSIG#:Signature”。 所以我的问题是如何修复它,因为在编辑模式下,XML是100%有效的? 谢谢你! XSD 更新#1 我试过不同的方法,但都不开心。 即使我用这种方法也不快乐。
下面是如何在LDAP Apache Directory Studio中创建组和用户的教程。 我使用posixGroup创建一个组来创建用户inetOrgPerson,posixAccound,shadowAccount 但是,条目不包含gidNumber和uidNumber并且不能添加。 如何为组添加gidNumber和为用户添加uid Number?