@Override
public T getById(ID id) {
Assert.notNull(id, ID_MUST_NOT_BE_NULL);
return em.getReference(getDomainClass(), id);
}
@Override
public Optional<T> findById(ID id) {
Assert.notNull(id, ID_MUST_NOT_BE_NULL);
Class<T> domainType = getDomainClass();
if (metadata == null) {
return Optional.ofNullable(em.find(domainType), id));
}
LockModeType type = metadata.getLockModeType();
Map<String, Object> hints = new HashMap<>();
getQueryHints().withFetchGraphs(em).forEach(hints::put);
return Optional.ofNullable(type == null ? em.find(domainType, id, hints) : em.find(domainType, id, type, hints));
}
사실 조회 기능을 구현하기 위해서는 어떤 메서드를 사용하든 상관없다
인 것으로 알고 있습니다만, 추가적인 의견 있으신 분은 알려주시면 압도적으로 감사드리겠습니다.🙇♂️
(책) 스프링부트 핵심 가이드 (지은이 - 장정우, 출판사 - 위키북스)