diff --git a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index 3726fbf57..c68c492ce 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -210,11 +210,15 @@ public class SimpleJpaRepository implements JpaRepos Assert.notNull(id, "The given id must not be null!"); + Class domainType = getDomainClass(); + + if (crudMethodMetadata == null) { + return em.find(domainType, id); + } + LockModeType type = crudMethodMetadata.getLockModeType(); Map hints = crudMethodMetadata.getQueryHints(); - Class domainType = getDomainClass(); - return type == null ? em.find(domainType, id, hints) : em.find(domainType, id, type, hints); } @@ -525,6 +529,10 @@ public class SimpleJpaRepository implements JpaRepos private TypedQuery applyRepositoryMethodMetadata(TypedQuery query) { + if (crudMethodMetadata == null) { + return query; + } + LockModeType type = crudMethodMetadata.getLockModeType(); TypedQuery toReturn = type == null ? query : query.setLockMode(type);