title: JPA Query table by date and state SpringBoot
body: <p>I want to pull data from two tables bookings table and routes table. Bookings table contains a foreign key route_id. What I want to do is spool from bookings table but also get the departure time and departure date from the routes table based on the foreign key which is a primary key on the routes table.</p>
  
  <p>I tried the following :</p>
  
  <pre><code>@Entity
  public class bookings {
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;
  
  @Nullable
  private String email;
  
  private String amount;
  
  private String phoneId;
  
  private Timestamp dateCreated;
  
  private int state;
  /* Bokkings state will have 3 states 1 =&gt; pending, 2 =&gt; booked and 3 =&gt; used*/
  
  @ManyToOne
  private routes routes;
  }
  </code></pre>
  
  <p>The routes entity :</p>
  
  <pre><code>@Entity
  public class routes {
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;
  
  @ManyToOne
  private busStations busStations;
  
  private String destination;
  
  private String price;
  
  private String departureTime; // So same routes but different depature times
  
  private Date departureDate; // So same routes but different depature dates
  
  private Timestamp dateCreated;
  
  @Nullable
  private String dateModified;
  }
  </code></pre>
  
  <p>I put the following in my Crud Repo Interface</p>
  
  <pre><code>    public interface bookingsRepository extends CrudRepository&lt;bookings, 
  Integer&gt; {
  
      List&lt;bookings&gt; findByRoutesDepartureDateAndState(Date date, int state);
  }
  </code></pre>
  
  <p>The issue I have is I can not pull the values from the tables with the Query I wrote in my Crud Interface. I know the query is wrong but I don't know how to fix it.</p>