tajpure / data-jpa-jdbc-template-example

Example of extending a Spring Data JPA Repository to execute a custom SQL statement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behavior

About

Example of extending a Spring Data JPA Repository to execute a custom SQL statement

License:Apache License 2.0


Languages

Language:Java 100.0%