Project

General

Profile

Actions

Defect #1551

closed

Method 'findIds' doesn't work with page request

Added by Ondřej Kopr about 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Radek Tomiška
Category:
Filters
Target version:
Start date:
03/14/2019
Due date:
% Done:

100%

Estimated time:
Affected versions:
Owner:

Description

The method findIds doesn't use correctly order by.

Example:

Pageable pageable = new PageRequest(0, 100, new Sort(Direction.ASC, IdmIdentity_.username.getName()));
Page<UUID> identities = identityService.findIds(filter, pageable, IdmBasePermission.READ);

throw error:

aused by: java.lang.IllegalArgumentException: Error occurred validating the Criteria
    at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:61)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736)
    at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)
    at com.sun.proxy.$Proxy160.createQuery(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:294)
    at com.sun.proxy.$Proxy160.createQuery(Unknown Source)
    at eu.bcvsolutions.idm.core.api.service.AbstractReadDtoService.findIds(AbstractReadDtoService.java:226)
    at eu.bcvsolutions.idm.core.api.service.AbstractReadDtoService$$FastClassBySpringCGLIB$$120a9283.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmIdentityService$$EnhancerBySpringCGLIB$$dc3f1ab.findIds(<generated>)
    at eu.bcvsolutions.idm.rpt.report.identity.IdentityRoleByIdentityDeduplicationExecutor.generateData(IdentityRoleByIdentityDeduplicationExecutor.java:102)
    at eu.bcvsolutions.idm.rpt.report.identity.IdentityRoleByIdentityDeduplicationExecutor$$EnhancerBySpringCGLIB$$bd53d1b3.generateData(<generated>)
    at eu.bcvsolutions.idm.rpt.api.executor.AbstractReportExecutor.generate(AbstractReportExecutor.java:64)
    ... 29 common frames omitted
Caused by: java.lang.IllegalStateException: No criteria query roots were specified
    at org.hibernate.jpa.criteria.CriteriaQueryImpl.validate(CriteriaQueryImpl.java:273)
    at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:58)
    ... 48 common frames omitted

Actions #1

Updated by Radek Tomiška about 5 years ago

  • Subject changed from Method 'findIs' doesn't work with page request to Method 'findIds' doesn't work with page request

When only 'id' is returned, then sorting on the different column is not possible => 'username' is not in result list. The only possible solution is to include all attributes used in sort into result list.

Actions #2

Updated by Radek Tomiška about 5 years ago

I prepared test:
https://github.com/bcvsolutions/CzechIdMng/commit/56addc4b66c242913acfe2266a9d9d299204a730#diff-7392a31737c6091076a5786dd607a06b

and I have to agree with you (you won a beer:)) - if sorting is not defined, then it not works too. I looked into implementation and fix will take more time.

Actions #3

Updated by Radek Tomiška about 5 years ago

  • Status changed from New to Needs feedback
  • Target version set to Quartz (9.6.0)
  • % Done changed from 0 to 90

I've fixed 'findIds' method, page request and sort works.

Commit:
https://github.com/bcvsolutions/CzechIdMng/commit/3562b1c249c9cbd55df5528cbeeeea8ab701f43e

Could you do a feedback, pls?

Note: there was just a bug, you still won a beer :), I hadn't a truth - sorting works, even if attribute is not in result list.

Actions #4

Updated by Ondřej Kopr about 5 years ago

  • Status changed from Needs feedback to Resolved
  • Assignee changed from Ondřej Kopr to Radek Tomiška
  • % Done changed from 90 to 100

Thank you. It's working correctly. Good detective job.

Actions #5

Updated by Radek Tomiška almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF