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.
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. I have used org.eclipse.persistence.jpa version 2.6.4.
Register Jsr310JpaConverters.class
by adding it as a base package class to your EntityScan annotation
eg
@EntityScan(
basePackageClasses = {YourAppplication.class, Jsr310JpaConverters.class}
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.