java - EJB 3 Eager loading -


i work ejb 3. have base class , there dependency classes b,c,d

@entity @table(name = "a") public class implements serializable {      @onetomany(cascade = cascadetype.all)     private list<b> bs;      @onetomany(cascade = cascadetype.all)     private list<c> cs;      @onetomany(cascade = cascadetype.all)     private list<d> ds;  } 

i have question. how can load tables eagerly? want use em.find(a.class, id);

you must use fetch attribute in onetomany annotation so:

@entity @table(name = "a") public class implements serializable {      @onetomany(cascade = cascadetype.all, fetch = fetchtype.eager)     private list<b> bs;      @onetomany(cascade = cascadetype.all, fetch = fetchtype.eager)     private list<c> cs;      @onetomany(cascade = cascadetype.all, fetch = fetchtype.eager)     private list<d> ds;  } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -