This sample application demonstrates the usage of Spring Data JPA repositories.
Important points in the code:
- Created custom implementation for JPQL query generation and execution in packages
com.company.sample.core.repositories.*
- Adding dependency on Spring Data JPA: build.gradle
- Repository interfaces for the project entities: com/company/sample/core/repositories
- Usage of the repositories in tests and in the application code
Limitations:
- Do not use entity names that may clash with SQL reserved words: order, like, select, etc.
- Custom queries has limited abilities, we do not match method parameter names and custom query parameter names.
- If you want to specify like clause with wildcards and parameters in query annotation, please use concat function and named parameters like in the example:
select ... where ... like concat('?', :name, '%')