I have a custom repository declared like below(written in Kotlin):
interface FooRepository : JpaRepository<Foo, Int> {
fun findByFoo(foo: String): List<Foo>
fun findByBar(bar: String): List<Foo> {
//custom implementation
}
}
data class Foo(var id: Int, var foo: String, var bar: String)
Both methods satisfy the naming convention of JPA repository, but I want to implement the second method (FooRepository.findByBar
) on my own. How can I prevent JPA from creating a query for it?
Note that my custom implementation involves computation logic, thus the @Query
annotation that allows for a custom query doesn't meet my requirement.
Besides, in the real situation, it's necessary and reasonable to do this, so don't post your answer or comment if you're trying to suggest for a "better" design pattern, like placing the implementation in the service layer, etc.