从具有多个预测的分离有限制的一列只获取一列
我有以下代码获取具有最新日期的“ Andamento”对象(我称为日期 - >数据)。
DetachedCriteria criteriaAndamento = DetachedCriteria.forClass(Andamento.class);
criteriaAndamento.setProjection(Projections.projectionList()
.add(Projections.max("data").as(null))
.add(Projections.groupProperty("processo").as("id"))
);
criteriaAndamento.add(Restrictions.sqlRestriction("DATE_FORMAT(`data`, '%d/%m/%Y') like '" + filter.getFilterValue().toString() + "%'"));
criteria.add(Property.forName("id").in(criteriaAndamento));
但是在这一行中,代码:criteria.add(property.forname(“ id”)。在(criteriaandamento)中);
它给出以下错误:
ERROR SqlExceptionHelper:129 - Operand should contain 1 column(s)...
因此,它期望脱离符号只有1列。但是,由于我需要两个预测,我只能选择一个列?还是删除另一个?
PS:我已经删除了“最大”投影并起作用,因此我需要某种方法来仅从此分离有限核管中选择“ Processo”列。
I have the following code to get the object which has the "Andamento" with the latest date (I have called date -> data).
DetachedCriteria criteriaAndamento = DetachedCriteria.forClass(Andamento.class);
criteriaAndamento.setProjection(Projections.projectionList()
.add(Projections.max("data").as(null))
.add(Projections.groupProperty("processo").as("id"))
);
criteriaAndamento.add(Restrictions.sqlRestriction("DATE_FORMAT(`data`, '%d/%m/%Y') like '" + filter.getFilterValue().toString() + "%'"));
criteria.add(Property.forName("id").in(criteriaAndamento));
But in this line of code: criteria.add(Property.forName("id").in(criteriaAndamento));
it gives the following error:
ERROR SqlExceptionHelper:129 - Operand should contain 1 column(s)...
So it expects the detachedCriteria to have only 1 column. But since I need both projections, how can I select only one column? Or maybe remove the other?
ps: I have removed the "max" projection and it works, so I need some way to select only the "processo" column from this detachedCriteria.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论