일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- db
- laravel
- java
- Spring Batch
- devops
- Web Server
- elasticsearch
- Git
- IntelliJ
- ReactJS
- it
- Gradle
- jsp
- Spring
- Design Patterns
- linux
- 요리
- JVM
- springboot
- php
- javascript
- Spring Boot
- 맛집
- ubuntu
- redis
- jenkins
- Oracle
- AWS
- MySQL
- tool
Archives
- Today
- Total
아무거나
[JPQL] JPQL 기본 사용 예 본문
반응형
[JPQL 사용]
Query annotation : Repository의 조회 메소드에 직접 실행될 쿼리를 작성
1. Controller.java
List<ProductLog> productLogs = productLogService.getProductLog(productLog, limit);
2. Service.java
List<ProductLog> getProductLog(ProductLog productLog, Integer limit);
3. ServiceImpl.java
@Override
public List<ProductLog> getProductLog(ProductLog productLog, Integer limit) {
return repository.sqlFindWmpVendorIdAndDataProviderProcessType(productLog.getWmpVendorId(), productLog.getDataProviderProcessType(), productLog.getRegisterdTime(), limit);
}
4. Repository.java
@Repository
public interface ProductLogRepository extends CrudRepository<ProductLog, Integer> {
@Query(value="SELECT * FROM categroy_product_logs WHERE wmp_vendor_id = :wmpVendorId AND data_provider_process_type = :dataProviderProcessType AND registerd_time = :registerdTime LIMIT :limit", nativeQuery = true)
List<ProductLog> sqlFindWmpVendorIdAndDataProviderProcessType(
@Param("wmpVendorId") String wmpVendorId,
@Param("dataProviderProcessType") Integer dataProviderProcessType,
@Param("registerdTime") Timestamp registerdTime,
@Param("limit") Integer limit
);
}
반응형
'Java & Kotlin > JPA' 카테고리의 다른 글
Comments