Play framework JPA query nested object not available
I have three objects that are related to eachother.

    @Entity
    class Club extends Model

       @OneToMany(cascade = CascadeType.ALL, mappedBy = "club")
       public Set<Car> cars;

    @Entity
    class Car extends Model

       @ManyToOne(cascade = CascadeType.PERSIST)
       public Club club;

    @Entity
    class Booking extends Model

       public Date startTime;
       
       @ManyToOne(cascade = CascadeType.PERSIST)
       public Car car;
       
       public static Collection<Booking> bookingsForClubInPeriod(Club club, Date start, Date end){
          return Booking.find("startTime > ? and startTime < ? and car.club = ?", start, end, club).fetch();
       }

I can search for Bookings that start between two times, but when I add car.club to the query, I get zero results.

I also tried changing the query to:
     find("startTime > ? and startTime < ? and car in ?", start, end, club.cars) but with no luck (that gave me this message: <i>Could not get a field value by reflection getter of models.Car.id</i>

Another try was to add FetchType.EAGER to both cars and club, but that didn't help either.

Also if I do a find on Car I can get the club, and the other way around. It's just in this query I can't find it.
The model objects are simplified, but should provide enough information to explain my problem.

Any Ideas why I can't query based on the nested object club?

 
Play framework JPA query nested object not available
===

I have three objects that are related to eachother.

    @Entity
    class Club extends Model

       @OneToMany(cascade = CascadeType.ALL, mappedBy = "club")
       public Set<Car> cars;

    @Entity
    class Car extends Model

       @ManyToOne(cascade = CascadeType.PERSIST)
       public Club club;

    @Entity
    class Booking extends Model

       public Date startTime;
       
       @ManyToOne(cascade = CascadeType.PERSIST)
       public Car car;
       
       public static Collection<Booking> bookingsForClubInPeriod(Club club, Date start, Date end){
          return Booking.find("startTime > ? and startTime < ? and car.club = ?", start, end, club).fetch();
       }

I can search for Bookings that start between two times, but when I add car.club to the query, I get zero results.

I also tried changing the query to:
     find("startTime > ? and startTime < ? and car in ?", start, end, club.cars) but with no luck (that gave me this message: <i>Could not get a field value by reflection getter of models.Car.id</i>

Another try was to add FetchType.EAGER to both cars and club, but that didn't help either.

Also if I do a find on Car I can get the club, and the other way around. It's just in this query I can't find it.
The model objects are simplified, but should provide enough information to explain my problem.

Any Ideas why I can't query based on the nested object club?

 