title: How to make generic jpa repository? Should I do this? Why?
body: <p>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.</p>
  
  <ol>
  <li><p>save()    </p></li>
  <li><p>update()   </p></li>
  <li><p>delete()</p></li>
  <li><p>findOne()</p></li>
  <li><p>findAll()</p></li>
  </ol>
  
  <p>Besides of above methods, I have other custom methods also in my applications.</p>
  
  <p>my aim is to implement GenericRepo like,</p>
  
  <pre><code>public interface MyGenericRepo extends JpaRepository&lt;GenericEntity,Integer&gt;
  {
  
  }
  </code></pre>
  
  <p>my entities will be like:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>when I call:</p>
  
  <pre><code>    MyGenericRepo myRepo;
  
      GenericEntity place=new Place();
  
      myRepo.save(place);
  </code></pre>
  
  <p>It should save place.</p>
  
  <pre><code>[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]
  </code></pre>
  
  <p>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...</p>
  
  <p>Thanks..</p>
  
  <p>How to make generic jpa repository? Should I do this? Why?</p>