The result of jpa query is not consistent with the reality.

when I integrate jpa with springboot, I have a custom query that does not match the actual execution result of mysql.
Custom query is as follows:

@Query("select o from MyOrder o where o.phoneNum=?1 and o.ostart>=?2")
List<MyOrder> findByPhoneNumAndOstartAfter(String phoneNum, Date date);

where the call is:

List<MyOrder> orders = orderRepository.findByPhoneNumAndOstartAfter(phoneNum, date);
//phoneNum="123456" date=Mon Oct 01 00:00:00 CST 2018

the sql statement for manually manipulating mysql is as follows:

select*from my_order where phone_num="123456" and ostart>="2018-10-01 00:00:00";

there is only one record for the result set that uses jpa, while five records actually meet the criteria. I thought it was the After in the interface, but I used @ Query to define the query and found that the result was still wrong. I don"t know what went wrong

Sep.28,2021

you add these two to the properties file, execute the query, print your custom SQL statement and take a look at

jpa.hibernate.show-sql=true
jpa.hibernate.format-sql= true
Menu