I am new to stack overflow and working on spring jpa data with hibernate and mysql. I have created One JpaRepository for each entity class. But now I feel that I should use One repository for all entities because In all my repositories has common CRUD operation methods.
save()
update()
delete()
findOne()
findAll()
Besides of above methods, I have other custom methods also in my applications.
my aim is to implement GenericRepo like,
public interface MyGenericRepo extends JpaRepository<GenericEntity,Integer>
{
}
my entities will be like:
class Place extends GenericEntity
{
private Event event;
}
class Event extends GenericEntity
{
}
class Offer extends GenericEntity
{
private Place place;
}
class User extends GenericEntity
{
private Place place;
}
when I call:
MyGenericRepo myRepo;
GenericEntity place=new Place();
myRepo.save(place);
It should save place.
[http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/jpa_overview_mapping_inher.html#jpa_overview_mapping_inher_joined][1]
I have referred above link and I found that Jpa Inheritance with Joined and Table-Per-Class strategies are similar to what I am looking for, but these all have certain limitations.So please tell me should I try to implement this generic thing.If I get any demo code then I will be very greatful...
Thanks..
How to make generic jpa repository? Should I do this? Why?