[英]Query by date(oracle date in db and local date in java entity) is not working in spring java
I am trying to query by date in spring repository class but its not working.Its working fine with local h2-database but its not working with Oracle database. 我正在尝试按春季存储库类中的日期查询,但它不起作用。它可以与本地h2-数据库正常工作,但不适用于Oracle数据库。
In controller class:- 在控制器类中:
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<OrderLine>> getOrderDetails(@RequestParam("headerSummaryId") Long headerSummaryId,
@RequestParam(value = "eventMonth",
required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate eventMonth) {
List<OrderLine> od = orderLineService.getOrderDetails(headerSummaryId, Optional.ofNullable(eventMonth));
return ResponseEntity.ok().body(od);
}
In service class:- 服务等级:
@Override
public List<OrderLine> getOrderDetails(Long headerSummaryId, Optional<LocalDate> eventMonth) {
List<OrderLine> olList = new ArrayList<>();
olList = orderLineSummaryRepo.findByHeaderSummaryIdAndEventMonthAndVisibleFlag(headerSummaryId,
eventMonth.get(), true);
return olList;
}
In repository class:- 在存储库类中:
List<OrderLine> findByHeaderSummaryIdAndEventMonthAndVisibleFlag(Long headerSummaryId, LocalDate eventMonth,
Boolean visibleFlag);
The date type for event month in entity class is LocalDate. 实体类中事件月份的日期类型为LocalDate。 I have used org.eclipse.persistence.jpa version 2.6.4.
我已经使用了org.eclipse.persistence.jpa版本2.6.4。
Register Jsr310JpaConverters.class
by adding it as a base package class to your EntityScan annotation 通过将
Jsr310JpaConverters.class
作为基本包类添加到EntityScan批注中来注册
eg 例如
@EntityScan(
basePackageClasses = {YourAppplication.class, Jsr310JpaConverters.class}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.