java - Hibernate Criteria API join through id -
when using criteria api, in order add filters entity referenced current one, use code:
criteria.createalias("customer", "customer", criteria.inner_join);
where customer customer entity property in entity criteria created for. problem is, need remove referenced entity , leave it's id in class, i.e. replace
@manytoone @joincolumn(name = "id_customer") private customerentity customer;
by
@column(name = "id_customer") private long customerid;
so, change need make in criteria alias in order keep working? filter example have on it, along join above:
criteria.add(restrictions.eq("customer.statusid", statusid));
Comments
Post a Comment