Spring DATA JPA Between and IsBetween keywords

You should do it in this way

SELECT * FROM users u WHERE e.REFERENCE_FIELD BETWEEN startDate AND endDate

Your code is not very clear, and I dont know what is 2016-02-15, if is the name of your field or is a value, if is a value and you are using between, you must specify a range, and a field to be compared.

EDIT

If you want to use spring data jpa then do it like this

findReferenceFieldBetween(value1,value2);

check the ref. here


In Spring boot: 2.1.6, you can use like below:

List<OrderSummaryEntity> findByCreateTimestampBetween(String fromDate, String toDate);

Just to confirm how it is working internally, If you put spring.jpa.properties.hibernate.show_sql=true property in applocation.properties file, you may see the query like below. Internally nothing but BETWEEN query only.

Hibernate: select order0_.order_id as order_id1_8_, 
           order0_.create_timestamp as create_t2_8_, 
           order0_.inventory_at_order as inventor3_8_,
           order0_.last_updated_by as last_upd4_8_,
           order0_.location_id as location5_8_, 
               ...
               ...
               ...
          from order_summary order0_ 
          where order0_.create_timestamp between ? and ?

If you want to include both boundary dates in result you can use below in Spring data jpa

@Query(value = "{'field' : {$gte : ?0, $lte : ?1}}", fields="{ 'field' : 1}")

List<DTO> findByFieldBetweenQuery(String first, String second);

Remove fields section if all fields are expected. Hope it helps someone.