Wednesday, 11 September 2013

spring data generic repository for multiple entites

spring data generic repository for multiple entites

I am new to spring data. I was able to set a simple set up working using
the following
public interface ContactRepository extends JpaRepository<Contact, Long>{}
But it looks like I will have to create a repository for each entity, even
if i am just interested in using the default methods that come with
JPARepository.
I tried to create a generic repository as follows
public interface GenericRepository<T, ID extends Long> extends
JpaRepository<T, ID>{}
But I am not able to inject an implementation of Generic repsitory,
because of generics. Can some one give a sample of how to use the
JpaRepository to manage different kind of entities

No comments:

Post a Comment