假设您有以下模型:
@Entitypublic class User extends Model { @Id @Column(name = "user_index") private int id; @Column(name = "user_first_name") private String firstName; [...] @oneToMany(mappedBy = "book_owner_index") private List<Book> books; public static Finder<Integer, User> find = new Finder<Integer, User>(Integer.class, User.class); [...]}和
@Entitypublic class Book extends Model { @Id @Column(name = "book_index") private int id; @Column(name = "book_name") private String name; @Column(name = "book_condition") private String condition; [...] @ManyToOne @JoinColumn(name = "book_owner_index", referencedColumnName = "user_index") private User owner; [...]}然后,您可以进行如下搜索:
List<User> users = User.find.select("*") .fetch("books") .where() .eq("books.condition", "new") .findList();


