Open smokeInCloud060201 opened 1 month ago
Thank you @smokeInCloud060201 for getting in touch. Please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Hi @christophstrobl. I understand why. I don't override the toPredicate() method
@Override
public Predicate toPredicate(Root<E> root,
CriteriaQuery<?> criteriaQuery,
CriteriaBuilder builder) {}
I do
Specification<Entity> specs = ((root, query, criteriaBuilder) -> {
...
return predicates;
};
and use this specs to findAll. That is reason. But have a little bit strange that's not at all Entity was missing. I use it for some Entity class but only one was missing.
And I also get a new issue. I don't know should I create new issue or tell it in hear.
That's Hibernate issue. In Hibernate 6.x.x we can not use same Join, Path,... with same CriteriaQuery
for more than 1 query.
Meaning for each query we need to rebuild the Predicate, Joining,... or copy it.
And you know when use JPA pageable feature, we need to run 2 queries, one to get records one to get total elements.
So, we will get the the error likes:
Already registered a copy: SqmSingularJoin
or something like that. I see many people got same issue with me when upgrade from SpringBoot 2.x.x to SpringBoot 3.x.x
I fixed that by use Hibernate feature instead JPA now, but I don't know if you already fix that or have plan to do that
I am using
SpringBoot-Starter-Data-JPA-Version: 3.3.3
. When I usePage<T> findAll(@Nullable Specification<T> spec, Pageable pageable)
, I will get 2 queries. The first query is correct, but the second query, with it's use to count total elements was missing a condition..The first query SQL result:
The second query, use to count total elements result:
The condition
and w1_0.status in (?, ?, ?, ?)
was missing in the countQuery So when I try to use findAll() to pageable will get incorrect result.