2014-11-14 63 views

回答

12

假设模型Student

@Entity 
public class Student{ 

@Id 
public int id; 

public String name; 
} 

型号取景器会

public static Finder<Long,Student> find = new Finder(Long.class, Student.class); 
public static Student getStudent() 
{ 
    // Use setMaxRows(limit_by) 
    return find.setMaxRows(1).findUnique(); 
} 
+0

感谢这个检索学生的限制。新的ebean,并写它setMaxRows(1).findList()。get(0),findUnique()似乎会更有效率。不知道他们为什么不仅仅提供findFirst()。 – 2015-11-17 18:47:20