I am quite familiar with the JdbcTemplate
object of Spring (and with spring-jdbc in general), and I really like writing the SQL and dealing with the object mapping myself.
However recently I was playing with the CrudRepository
interface and I really liked it.
That said, I still favor writing my own SQLs queries when it comes to a complex query (joins and so on).
I would like to be able to use the CrudRepository
methods in a class that also has a JdbcTemplate
instance, that way I could have the out of the box methods of CrudRepository
while being able to write my own complex SQLs and use them with JdbcTemplate
.
The problem is, of course, that CrudRepository
is just an interface while JdbcTemplate
is a regular class. So the question is
- Does any of what I am mentioning actually make sense?
- Assuming that answer to (1) is yes, how would I be able to have a class with an instance of a
JdbcTemplate
that also provides an implementation ofCrudRepository
without having to hack my way around it too much?