title: JPA find by date between two dates
body: <p>here I'm trying to use JPA fetch the data from MYSQL DB, but I'm facing trouble to set data object to handle the condition, as I understand I have to create and data object to handle it,how do i creat date object to handle the needed </p>
  
  <p>here my normal query :</p>
  
  <pre><code>select t.id, t.MSISDN, t.Param1, t.param2
    from BULK_REPOSITORY t
  where t.Camp_Start_Date between Sysdate - 2 and sysdate
     and t.status = 0
     and t.camp_type = 1;
  </code></pre>
  
  <p>application : </p>
  
  <pre><code>@SpringBootApplication
  public class AccessingDataJpaApplication {
  
      private static final Logger log = LoggerFactory.getLogger(AccessingDataJpaApplication.class);
      Bulk_repository bulk ;
  
  
      public static void main(String[] args) {
          SpringApplication.run(AccessingDataJpaApplication.class);
      }
  
  
      @Bean
      public CommandLineRunner demo(Bulk_repositoryRepository repository) {
          return (args) -&gt; {
  
              // fetch customers by Status
              log.info("Customer found with findByStatus('0'):");
              log.info("--------------------------------------------");
              repository.findAllByStatusAndCampTypeAndCampStart_dateBetween(1,2,Date,Date-2).forEach(on -&gt; {
                  log.info(on.toString());
              });
          };
      }
  </code></pre>
  
  <p>Bulk_repository class :</p>
  
  <pre><code>@Entity
  @Table(name = "BULK_REPOSITORY")
  public class Bulk_repository {
  
     @Id
     @GeneratedValue(strategy=GenerationType.AUTO)
     @Column(name = "id")
     private long id;
  
     @Column(name = "msisdn")
     private String msisdn;
  
     @Column(name = "camp_start_date")   
     private Date campStartDate;
  
     @Column(name = "camp_end_date")
     private Date campEndDate;
  
     @Column(name = "camp_type")
     private int campType;
  
     @Column(name = "camp_cd")
     private String camp_cd;
  
     @Column(name = "status")
     private int status;
  
     @Column(name = "process_date")
     private Date processDate;
  
     @Column(name = "entry_date")
     private Date entryDate;
  
     @Column(name = "entry_user")
     private String entry_user;
  
     @Column(name = "param1")
     private String param1;
  
     @Column(name = "param2")
     private String param2;
  
     @Column(name = "param3")
     private String param3;
  
     @Column(name = "param4")
     private String param4;
  
     @Column(name = "param5")
     private String param5;
  
     @Column(name = "error_desc")
     private String error_desc;
  
     @Column(name = "fulfilment_status")
     private int fulfilment_status;
  ## getter and setter and ToString
  </code></pre>
  
  <p>Bulk_repositoryRepository class :</p>
  
  <pre><code>  import org.springframework.data.repository.CrudRepository;
  
      public interface Bulk_repositoryRepository extends CrudRepository&lt;Bulk_repository, Long&gt; {
            List&lt;Bulk_repository&gt;  findAllByStatusAndCampTypeAndCampStart_dateBetween(int status, int campType,Date campStart_dateStart, Date campStart_dateEnd);
           Bulk_repository findById(long id);
      }
  </code></pre>