What is your personal opinion about the getSingleResult method?
There are many discussions about it and most of the people seem to implement kind of a helper method.
Something like the following:
public static <T> T getSingleResultOrNull(TypedQuery<T> query) {
query.setMaxResults(1);
List<T> list = query.getResultList();
if (list.isEmpty()) {
return null;
}
return list.get(0);
}
Do you think it would make sense to add such a utility method?
Hi @BalusC
What is your personal opinion about the
getSingleResult
method? There are many discussions about it and most of the people seem to implement kind of a helper method. Something like the following:Do you think it would make sense to add such a utility method?