java - NullPointerException with Hibernate FETCH JOIN -
i nullpointerexception when executing list method on hibernate query. code:
session session = hibernateutil.getsessionfactory().opensession(); session.begintransaction(); string hql = "select g devicegroup g join fetch g.devices"; query query = session.createquery(hql); list<devicegroup> list = query.list(); session.gettransaction().commit(); session.close(); return list;
the relationship defined this:
device:
@manytoone @joincolumn private devicegroup devicegroup;
devicegroup:
@onetomany(mappedby = "devicegroup") private set<device> devices;
if leave out fetch join, list method succeeds, lazy fetching results in stackoverflowexception. doing wrong?
try identifier d
on g.devices
,
select g devicegroup g join fetch g.devices d
Comments
Post a Comment