ProductRepository 2022/04/19
파일명 ProductCountRepository.java
package com.example.repository;
import com.example.entity.ProductCountEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductCountRepository extends JpaRepository<ProductCountEntity, Long>{
    
    @Query(value = "SELECT SUM(CNT) FROM PRODUCTCOUNT WHERE PRODUCT_NO=:no GROUP BY PRODUCT_NO", nativeQuery = true)
    public long selectProductCountGroup(
        @Param(value = "no")Long ProductNo );
    // nativeQuery에서 insert, update, delete는 데이터의 변화가 생심 @Modifying(clearAutomatically = true) 사용
    @Modifying(clearAutomatically = true)
    @Query(value = "DELETE FROM PRODUCT WHERE CNT >= :cnt", nativeQuery = true)
    public long deleteProductCountGroup(
        @Param(value = "cnt") Long cnt   );
    
    @Modifying(clearAutomatically = true)
    int deleteByCnt(long cnt);
    // findBy... SELECT
    
    // deleteBy ... DELETE
    // INSERT, UPDATE는 사용 X
}
파일명 ProductViewRepository.java
package com.example.repository;
import com.example.entity.ProductViewEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductViewRepository extends JpaRepository<ProductViewEntity, Long>{
    
}
                Author And Source
이 문제에 관하여(ProductRepository 2022/04/19), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@anrkfl/ProductRepository-20220419저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)