Spring Data JDBC support
lpandzic opened this issue · 8 comments
Spring Data JDBC provides an alternative way to defining entities in model that is a lot more concise and flexible (e.g. a lot less annotations are necessary and models can be truly immutable) compared to JPA. Can support be added for such models?
That is an interesting case. Working closely with JPA I never explored that option deeply. I will investigate it. That being said it may be the case when too small number of annotations is a problem instead of advantage.
EntityQL (for now at least) requires an Entity that is fully described using JPA Annotations. It doesn't use any magic to resolve/assume the DB Object names. That's why Annotations like @Table/@Column/@joincolumn are required for EntityQL to work.
Using Models with small number of Annotations would mean that we have to resolve/compute DB Object names from Java names directly.
Having all the JPA Annotations in place means we have less ambiguity.
There are annotations similar to the ones in JPA like @Column
etc. but most of them are optional and there's a convention in place in order to reduce boilerplate/clutter which I really like. Also, a lot can be solved with NamingStrategy that's also documented in reference documentation. It seems those defaults should be easily appliable here, as well as autowiring the naming strategy while generating query classes.
Here's an example of how it can be used in practice.
Hmm the idea seems tempting. I'll look around the code and get back to you in few days :)
For now I've decoupled the JPA Metedata extraction from the rest of the code. Please look at this package. In there there is an Interface for extracting the Metadata from a Class alongside with default JPA implementation.
I don't have time to analyze Spring's JDBC implementation right now. Would you be willing to implement the QEntityScanner for Spring JDBC? I can see that you know the grounds already.
I would want to avoid backwards engineering Spring JDBC - I would rather find the mechanism inside the Spring JDBC that extracts the Metadata from their Entities and use it in the custom QEntityScanner.
What do you think?
2.20 released with Spring Data JDBC integrated and tested. Thank you @lpandzic for your contribution!
You're welcome. Is there a way to use this new addition with static compilation or something needs to be added to the maven plugin?
I will work on the Maven plugin as soon as I can to add the ability of using Spring Data JDBC. For now you have to use QExporter
Does this project currently support Jakarta?