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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -