I have the following method that returns a Person
object by Id:
private Person getPersonById(String client) {
Person output = null;
EntityManager entityManager = null;
try {
entityManager = entityManagement.createEntityManager(client);
output = entityManager.find(Person.class, id);
} catch (Exception e) {
// handle
} finally {
entityManagement.closeEntityManager(client, entityManager);
}
return output;
}
Is there a way I can make this method more generic so that I can pass in other object types, e.g.
Place
, Cost
as well? Note that these do not inherit the same super class.
E.g. should I pass e.g. Person.class
as a method parameter etc?