I have a function as follows:
public boolean delete(int id) {
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    em.remove(em.find(Student.class, id));
    em.getTransaction().commit();
    return true;
}
Now i want the above function to be a generic one. So i implemented the same in the following way:
 public boolean genericDelete(int id, Object ob) {
     EntityManager em = emf.createEntityManager();
     em.getTransaction().begin();
     em.remove(em.find((Class) ob, id));
     em.getTransaction().commit();
     return true;
 }
The function is working without any flaw but IntellijIDEA complains about object being casted to Class. It might be a bad practice, so how to implement the same in a proper manner. Please help...
 
    