@@ -203,7 +203,7 @@ public interface UserRepository extends <% if (databaseTypeSql) { %>JpaRepositor
203203 < % _ if (! authenticationTypeOauth2) { _% >
204204 < % _ if (databaseTypeCouchbase || databaseTypeMongodb || databaseTypeNeo4j) { _% >
205205 < % _ if (cacheProviderAny) { _% >
206- @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE )
206+ @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE , unless = " #result == null " )
207207 < % _ } _% >
208208 < % _ } _% >
209209 < % if (databaseTypeCouchbase) { % > default < % } % >< %= optionalOrMono % > << %= user .persistClass % >> findOneByEmailIgnoreCase (String email)< % if (! databaseTypeCouchbase) { % > ;< % } else { % > {
@@ -219,14 +219,14 @@ public interface UserRepository extends <% if (databaseTypeSql) { %>JpaRepositor
219219 < % _ } _% >
220220 < % _ if (databaseTypeCouchbase) { _% >
221221 < % _ if (cacheProviderAny) { _% >
222- @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE )
222+ @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE , unless = " #result == null " )
223223 < % _ } _% >
224224 default < %= optionalOrMono % > << %= user .persistClass % >> findOneByLogin (String login ) {
225225 return findById (login);
226226 }
227227 < % _ } else if (databaseTypeMongodb || databaseTypeNeo4j) { _% >
228228 < % _ if (cacheProviderAny) { _% >
229- @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE )
229+ @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE , unless = " #result == null " )
230230 < % _ } _% >
231231 < %= optionalOrMono % > << %= user .persistClass % >> findOneByLogin (String login);
232232 < % _ } else { _% >
@@ -241,14 +241,14 @@ public interface UserRepository extends <% if (databaseTypeSql) { %>JpaRepositor
241241 < % _ if (databaseTypeSql) { _% >
242242 @EntityGraph (attributePaths = " authorities" )
243243 < % _ if (cacheProviderAny) { _% >
244- @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE )
244+ @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE , unless = " #result == null " )
245245 < % _ } _% >
246246 Optional<< %= user .persistClass % >> findOneWithAuthoritiesByLogin (String login);
247247
248248 < % _ if (! authenticationTypeOauth2) { _% >
249249 @EntityGraph (attributePaths = " authorities" )
250250 < % _ if (cacheProviderAny) { _% >
251- @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE )
251+ @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE , unless = " #result == null " )
252252 < % _ } _% >
253253 Optional<< %= user .persistClass % >> findOneWithAuthoritiesByEmailIgnoreCase (String email);
254254
@@ -609,15 +609,15 @@ public class UserRepository {
609609 }
610610
611611 < % _ if (cacheProviderAny) { _% >
612- @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE )
612+ @Cacheable (cacheNames = USERS_BY_EMAIL_CACHE , unless = " #result == null " )
613613 < % _ } _% >
614614 public < %= optionalOrMono % > << %= user .persistClass % >> findOneByEmailIgnoreCase (String email ) {
615615 BoundStatement stmt = findOneByEmailStmt .bind ().setString (" email" , email .toLowerCase ());
616616 return findOneFromIndex (stmt);
617617 }
618618
619619 < % _ if (cacheProviderAny) { _% >
620- @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE )
620+ @Cacheable (cacheNames = USERS_BY_LOGIN_CACHE , unless = " #result == null " )
621621 < % _ } _% >
622622 public < %= optionalOrMono % > << %= user .persistClass % >> findOneByLogin (String login ) {
623623 BoundStatement stmt = findOneByLoginStmt .bind ().setString (" login" , login);
0 commit comments