how to ignore fetching a child table in hibernate -
i have 2 tables . health & network
this health table entity:
@table(name="health") public class health implements serializable { private static final long serialversionuid = 1l; @id @column(name="hid") private int hid; @column(name="ivid") private int ivid; @joincolumn(name = "nwid") @manytoone(fetch = fetchtype.lazy) private networks nwid;
}
i trying fetch health row against there nothing available in network table , thats why not giving me rows record of health table..
where want row health , dont want network table record..
if dont use crit.createalias... server call failed.
try { session = sessionfactory.opensession(); criteria crit = session.createcriteria(health.class); crit.createalias("nwid", "network"); crit.createalias("network.statsid", "stats"); crit.add(restrictions.eq("ivid", 0)); iterator<health> = crit.list().iterator(); while(it.hasnext()){ health = it.next(); }
try change this:
crit.createalias("nwid", "network");
to
crit.createalias("nwid", "network", criteriaspecification.left_join);
Comments
Post a Comment