#315 - Add example for Spring Data JDBC usage with jOOQ#385
#315 - Add example for Spring Data JDBC usage with jOOQ#385florianluediger wants to merge 4 commits intospring-projects:masterfrom florianluediger:master
Conversation
schauder
left a comment
There was a problem hiding this comment.
About the duplicated classes. This might help: https://www.jooq.org/doc/3.9/manual/sql-execution/fetching/pojos/
| @@ -0,0 +1,60 @@ | |||
| /* | |||
| * This file is generated by jOOQ. | |||
There was a problem hiding this comment.
Generated files shouldn't be checked into version control. Obviously applies to all generated files.
There was a problem hiding this comment.
I have used this example as a reference, so I included the generated sources. I will remove these because I also think it makes no sense to include them.
jdbc/jooq/pom.xml
Outdated
| <dependency> | ||
| <groupId>org.jooq</groupId> | ||
| <artifactId>jooq</artifactId> | ||
| <version>3.11.0</version> |
There was a problem hiding this comment.
Avoid putting versions directly into dependencies.
Ideally remove them completely.
They might be already defined by an upstream pom.xml.
If they aren't extract them into a property.
| } | ||
|
|
||
| @Bean | ||
| public ApplicationListener<BeforeSaveEvent> timeStampingSaveTime() { |
There was a problem hiding this comment.
Please remove all code not essential for this example. Simplify the model if necessary.
|
|
||
| List<Category> getCategoriesWithAgeGroup(AgeGroup ageGroup) { | ||
| Result<Record> res = this.dslContext.select().from(CATEGORY).where(CATEGORY.AGE_GROUP.equal(ageGroup.name())).fetch(); | ||
| List<Category> categoryList = new ArrayList<Category>(); |
There was a problem hiding this comment.
Can we use this for the conversion? https://www.jooq.org/javadoc/3.9.x/org/jooq/Result.html#into-java.lang.Class-
There was a problem hiding this comment.
We can and I think it's a very elegant solution - done
| * @author Florian Lüdiger | ||
| */ | ||
| @Component | ||
| public class JooqMethods { |
There was a problem hiding this comment.
This shouldn't be an arbitrary component but a custom implementation for a repository method. See https://docs.spring.io/spring-data/jdbc/docs/1.0.0.RC1/reference/html/#repositories.custom-implementations
There was a problem hiding this comment.
I really like that approach, it works really well!
jdbc/jooq/README.adoc
Outdated
| To rerun the code generator, just execute the following commands: | ||
| [indent=0] | ||
| ---- | ||
| $ rm -rf gensrc |
There was a problem hiding this comment.
is the rm really necessary? that really should be done by the clean of the mvn call.
There was a problem hiding this comment.
mvn clean does not actually delete the generated sources. However these get ovewritten by the mvn generate-sources command, so I guess this step is not really necessary.
|
Thank you @schauder for your detailed review, it really is a lot of fun to work on this issue and I think I'm learning a lot! I have fixed the things you pointed out and hope that everything is okay now. If not, feel free to hit me up again. |
Demonstrating how to use jOOQ as the basis for an implementation of custom repository methods. Original pull request: #385.
Used default directory for code generation. Formatting. Simplified asserts with some AssertJ trickery. Original pull request: #385.
|
Thanks for the work. I squashed, polished and merged. |
|
Where is example.springdata.jdbc.basics.simpleentity.domain.tables.Category.CATEGORY coming from? Can't find it anywhere in any branches. |
|
@dashirov-fl this is generated by JOOQ. |
This sample shows the concurrent usage of Spring Data JDBC wit jOOQ.
I am not particularly happy with the fact that there is a
Categoryclass for both Spring Data JDBC and jOOQ and that I have to map them onto each other in theJooqMethodsclass. If you have any suggestions on how to improve this, feel free to give me a heads up.