-
Couldn't load subscription status.
- Fork 26
Add utilities for Pageable to be used with Doma Criteria. #275
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
Add utilities for Pageable to be used with Doma Criteria. #275
Conversation
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/PageablesForCriteria.java
Outdated
Show resolved
Hide resolved
|
Thank you for your contribution! ./mvnw formatter:formatNote On Windows, you may need to explicitly pass the current directory using the -DrootDir option. |
|
Oh! I’m sorry! I applied the formatting! |
…re no matching columns.
|
Please don't worry about it! I'll be reviewing it over the weekend, so please wait a little longer. |
|
@mazeneko However, if you don’t mind, I’d like to start by discussing the API design. Personally, I prefer aggregating operations related to a class and exposing them as instance methods. For example, what do you think about writing it like this? public Page<Task> getPage(Pageable pageable) {
final var task_ = new Task_();
final var p = UnifiedQueryPageable.from(pageable, task_);
final var content = this.queryDsl
.from(task_)
.offset(p.offset())
.limit(p.limit())
.orderBy(p.sort())
.fetch();
final var total = this.queryDsl
.from(task_)
.select(Expressions.count())
.fetchOne();
return new PageImpl<>(content, pageable, total);
}I believe this approach is more concise and easier to read compared to something like What do you think? |
|
@backpaper0 |
|
@backpaper0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve reviewed the code.
Thank you for accommodating my suggestion to introduce the UnifiedQueryPageable class.
I truly enjoyed reading through your code.
I’ve left some comments on points that caught my attention, as well as a few requests. I’d appreciate it if you could take a look.
Note
I expect we’ll go back and forth once or twice more, but please keep in mind that none of this is a criticism of you personally.
I hope you’ll enjoy the discussion with me.
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/UnifiedQueryPageable.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/UnifiedQueryPageable.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/UnifiedQueryPageable.java
Show resolved
Hide resolved
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/UnifiedQueryPageable.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedQueryPageableTest.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedQueryPageableTest.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedQueryPageableTest.java
Outdated
Show resolved
Hide resolved
|
Thank you for your thorough review! |
doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedQueryPageableTest.java
Outdated
Show resolved
Hide resolved
doma-spring-boot-core/src/test/java/org/seasar/doma/boot/UnifiedQueryPageableTest.java
Show resolved
Hide resolved
doma-spring-boot-core/src/main/java/org/seasar/doma/boot/UnifiedQueryPageable.java
Show resolved
Hide resolved
Co-authored-by: Uragami Taichi <backpaper0@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for patiently sticking with the review process!
I’m approving and merging this pull request.
|
Thank you so much for all the thoughtful reviews and advice throughout the process! |
|
@mazeneko When transitioning from a static utility to a class, I initially proposed the name Since it's just a simple rename via the IDE, I considered fixing it myself. If you're okay with it, would you mind creating a pull request to rename it? |
|
By the way, while I was preparing for the release, I thought it would be a good opportunity to add a simple sample using Query DSL. That’s when I noticed the naming mistake (of course, I’ll be using the feature you created as well!). |
|
@backpaper0 |
Good evening! I'm always grateful for how convenient doma-spring-boot is!
I really like Doma criteria API, and there are times when I wish there were a criteria-based version of Pageables.
So, I tried creating something that can be used like this:
If you’re interested, please take a look!
(P.S. This is my first time trying to contribute, so I apologize in advance if I’m doing anything inappropriate.)