简体   繁体   中英

How to fetch data from database by using Date in Spring boot?

I create a project on spring boot and project connected with H2 database. Save the data in a database through the post Mapping rest API but parameter of our class name , id , address and LocalDate date.

I fetch the data data through using getOrderById method but i can't fetch the data between two dates.

Help me to fetch the data between two dates by using spring boot REST API.

Entity Class Order

This query might help you to get the right result.

@Query(nativeQuery = true, value="select  from Order o where o.date between :startDate and :endDate")
List<Order> getOrderById(@Param("startDate") LocalDate date1, @Param("endDate") LocalDate date2);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM