我有两个类,并在此处编写ebean查询:
@Entity
public 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;
@Column(name = "crated_date")
private Long cratedDate;
}
和
@Entity
public 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;
@Column(name = "crated_date")
private Long cratedDate;
}
List<User> users = User.find.select("*")
.fetch("books")
.where()
.eq("crated_date", "some")
.findList();
我遇到错误crated_date is ambiguous column
:
List<User> users = User.find.select("*")
.fetch("books")
.where()
.eq("User.crated_date", "some")
.findList();
上述查询对我来说Unknown column User.crated_date
无效。
当我写t0.crated_date
时它正在工作-它只是一个hack,有人可以建议我一种正确的写方法吗?
当我为Book类编写查询(通过编写objectName.propertyName
-book.crated_date
)而不是为User类编写查询时,它确实起作用-为什么这样做?