Skip to content
Example of extending a Spring Data JPA Repository to execute a custom SQL statement
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Spring Data Custom Repository Extension Example

There is a perception that there is something akin to a binary choice between using Spring Data and accepting JPA or being able to use SQL (through JdbcTemplate) and have access to all it's flexibility.

This project is an example of how Spring Data JPA offers the ability to extend a Repository interface with a custom repo and in the custom repository use JdbcTemplate to execute a query.

The example query isn't a good use case of when to implement this behavior, as it Spring JPA is easily capable of handling a LIKE query, but the point isn't to demonstrate a meaningful use case, but how to implement the pattern.

For more complete check out the article: JPA or SQL in a Spring Boot Application? Why Not Both?

As well as the Spring Data JPA user docs:

You can’t perform that action at this time.