"final" empêche-t-il de modifier un objet retourné ?
Bonjour, pourriez vous me dire si res, apres avoir été retourné par cette méthode, peut etre modifié ?
merci de votre réponse
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
@Override
public final T findById(final Integer pId) {
final EntityManager em = EntityManagerUtils.createEntityManager();
try {
final CriteriaBuilder cb = em.getCriteriaBuilder();
final CriteriaQuery<T> cq = cb.createQuery(getEntityClass());
final Root<T> r = cq.from(getEntityClass());
cq.where(cb.equal(r.get(PRIMARY_KEY_PROPERTY), pId)));
cq.select(r);
final TypedQuery<T> tq = em.createQuery(cq);
final T res = tq.getSingleResult();
return res;
} catch (final NoResultException e) {
LOGGER.warning(e.getMessage());
return null;
} finally {
EntityManagerUtils.close(em);
}
} |