How can I get Lazy fields using Entity Manager? Here is my code snippet
public class Internet implements Serializable{ int id;
This is my browser hibernate class;
public class Browser implements Serializable{ int id; String name;
Now my requirement is that I want the name of the browser when I get the browser instance using the EntityManger find method using Internet.id.
These two classes are in different packages. therefore, I cannot directly access browser.name. I need a browser name. when I debug my browser.name program gets zero. Is there any way to get the value of the name browser.name using EntityManager.
I read a few posts related to this question, but I had no idea. Can any body help me?
This is my code, how I use my pages and a few things:
InternateObjectUsingPage usingPage = (InternateObjectUsingPage)pageWithName(InternateObjectUsingPage.class.getName()); _em = EntityManager.createEntityManager(); Internet ipReg = _em.find(Internet.class, _currentRow.getIpRegId()) ; // _currentRow.getInRegId() is id. ipReg.getBrowser(); // recently i added as per the suggestion. if(ipReg != null){ _refresh = true; usingPage.setInternet(ipReg); return usingPage; } _em.close();
that I use my code, but I do not see any difference.
source share