I am using play framework(java) 1.2.4, jpa and hibernate.How can i check relation(oneToMany) model filed value on find error occurred
Contry model:
@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 model:
@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() { }
}
In Contry controller:
List<Countries> countries = Countries.find("states.product_id =5").fetch();
When i check states table value (oneToMany) following error occurred:
IllegalArgumentException occured : org.hibernate.QueryException: illegal attempt to dereference collection