@Repository public interface UserRepository extends JpaRepository<User, Long> { Optional<User> findOneByActivationKey(String activationKey); List<User> findAllByActivatedIsFalseAndActivationKeyIsNotNullAndCreatedDateBefore(Instant dateTime); Optional<User> findOneByResetKey(String resetKey); Optional<User> findOneByEmailIgnoreCase(String email); Optional<User> findOneByLogin(String login); @EntityGraph(attributePaths = "authorities") Optional<User> findOneWithAuthoritiesByLogin(String login);
这是前同事写的代码,好奇这个注解有什么用
好像是用来解决n+1问题的,n+1问题是啥我也没搞懂
参考:
@EntityGraph的使用_Mosqiote的博客-CSDN博客_@entitygraph
解决JPA懒加载典型的N+1问题-注解@NamedEntityGraph - EalenXie - 博客园 (cnblogs.com)
JPA中@EntityGraph注解的作用_火山彬的博客-CSDN博客_jpa @entitygraph
JPA效率优化—@EntityGraph - 掘金 (juejin.cn)
标签:String,JPA,博客,干嘛,EntityGraph,注解,Optional From: https://www.cnblogs.com/wYYBLH/p/17047020.html