我使用的遊戲框架(Java)1.2.4,JPA和hibernate.How我可以查看關係(一對多)模型提交值上出現錯誤發現如何在一個檢查條件,許多關係模型提交值在JPA
Contry型號:
@Entity
public class Countries extends Model {
@Required
public String name;
public String iso2;
public String iso3;
@OneToMany(mappedBy="country", fetch=FetchType.EAGER, cascade=CascadeType.All)
public List<States> states;
public Countries() { }
}
State模式:
@Entity
public class States extends Model {
@Required
public long country_id;
@Required
public String name;
@Required
public long product_id;
@ManyToOne(fetch=FetchType.EAGER)
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name="country_id", nullable=false,insertable=false, updatable=false)
public Countries country;
public States() { }
}
在Contry控制器:
List<Countries> countries = Countries.find("states.product_id =5").fetch();
當我檢查以下錯誤狀態表中的值(一對多)發生:
IllegalArgumentException occured : org.hibernate.QueryException: illegal attempt to dereference collection