How to get access to the entity manager in the repository when we use spring boot and spring data?
Otherwise, I will need to put my big query in annotation, I would prefer to have something clear... then a long text.
How to get access to the entity manager in the repository when we use spring boot and spring data?
Otherwise, I will need to put my big query in annotation, I would prefer to have something clear... then a long text.
You would define a
CustomRepository
to handle such scenarios. Consider you haveCustomerRepository
which extends the default spring data JPA interfaceJPARepository<Customer,Long>
Create a new interface
CustomCustomerRepository
with a custom method signature.Extend
CustomerRepository
interface usingCustomCustomerRepository
Create an implementation class named
CustomerRepositoryImpl
which implementsCustomerRepository
. Here you can inject theEntityManager
using the@PersistentContext
. Naming conventions matter here.