-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem when using Sort.by #3721
Comments
Thank you for getting in touch. It would be great if you could take the time to reduce the linked sample application to a minimum. So just the repository, a failing testcase and if possible something using plain JPA without the spring bits to see if it is a spring or a persistence provider problem. Ideally using Testcontainers so that we can unzip or git clone, build, and deploy the reproducer. |
sorry for late reply, I was so busy.. in the test code, method t4 is the checking method, and t1, t2, t3 is for generating database entity. |
@oungsi2000 Thank you for providing the sample. select tem1_0.id,tem1_0.test_entity_one_id
from test_entity_many tem1_0
left join test_entity_many_voter v1_0 on tem1_0.id=v1_0.test_entity_many_id
where tem1_0.test_entity_one_id=?
order by v1_0.voter_id desc,tem1_0.id
limit ?,? You may enable logging to see it by setting: logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.orm.jdbc.bind=trace Since swapping the database to eg. HSQL works fine for both |
this is my whole code
https://github.com/oungsi2000/jump-to-springboot
When I use JpaRepository with Sort.by and Pageable, I got some mismatch with this.
com.ll.jumptospringboot.domain.Answer.AnswerService.getList
com.ll.jumptospringboot.domain.Answer.Answer
when using 'sorts.add(Sort.Order.desc("voter"));', If there are two or more voters, this.a
nswerRepository.findAllByQuestion(question, pageable); -> this doesn't get all Answers, instead gets pagination - 1 Answers
this is the result when the code above 'if (Objects.equals(sortBy, "mostVoted"))~~' executed
asdfad
this is the result when the code above 'else~~' executed
스크린샷 2024-12-18 오후 8 39 05
both counts should be same because the count means "All Answers" and it gets from same DB, same Hibernate query.
the difference between those is only 'sorts.add(Sort.Order.desc("voter"));' and attribute voter is @manytomany.
It is more strange that when the Entity Answer gets only one voter attribute, it works perfectly(both count is same) but when it gets two or more voter attribute, it just returns 9, not all of All Answers.
Please Help
If my English is Bad, I'm sorry. If you need extra explanation, Please notify me.
The text was updated successfully, but these errors were encountered: