Ebean ManyToMany query

前端 未结 1 1241
清酒与你
清酒与你 2021-01-04 23:55

I have two classes, user and car. Both have ManyToMany mapping to each other.

User:

@Entity
public class User extends Model {

    private int year;
         


        
相关标签:
1条回答
  • 2021-01-04 23:59

    Check similar question (and answer)

    Most probably your finder should look like:

    public List<Car> findCars(int year, User user) {
        return find.where().eq("year", year).eq("users.id", user.id).findList();
    }
    

    BTW I assume that you have some id field but just didn't show us. Also make your fields public, so you won't need to write getters/setters for each.

    0 讨论(0)
提交回复
热议问题