UserAddressRepo.java 835 B

123456789101112131415161718192021222324
  1. package com.izouma.nineth.repo;
  2. import com.izouma.nineth.domain.UserAddress;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import javax.transaction.Transactional;
  8. import java.util.List;
  9. public interface UserAddressRepo extends JpaRepository<UserAddress, Long>, JpaSpecificationExecutor<UserAddress> {
  10. @Query("update UserAddress t set t.del = true where t.id = ?1")
  11. @Modifying
  12. @Transactional
  13. void softDelete(Long id);
  14. List<UserAddress> findAllByUserId(Long userId);
  15. @Query("update UserAddress t set t.def = false where t.userId = ?1")
  16. @Modifying
  17. @Transactional
  18. void unsetDefault(Long userId);
  19. }