[appengine-java] Re: Lazy Loading, Spring MVC and PersistenceManager Closing
Interesting - thanks to both, will check out both options. On Dec 14, 8:52 pm, abhi abhishek9...@gmail.com wrote: Hey , why do you want to close the persistance manager here, you are not saving or updating any entities. You should use a static PMF class to get the entity manager und you feed class should have something like this ... class FEED { private static PersistenceManager pm; // this fetches the persistance manager when u need it. private static PersistenceManager getPM() { if (pm == null) { pm = PMF.get().getPersistenceManager(); } else if (pm.isClosed()) { pm = PMF.get().getPersistenceManager(); } return pm; } @SuppressWarnings(unchecked) public static ListFEED getAll() { PersistenceManager pm = getPM(); String sqlFetch = SELECT FROM + FEED.class.getName(); Query query = pm.newQuery(sqlFetch); query.setOrdering(name asc); query.setRange(0, 50); ListFEED feeds = (ListFEED)query.execute(); return feeds; } Convinienty in your handleRequestInternal calss u can get the results - ListFeed feeds = FEEDS.getAll(); -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: Lazy Loading, Spring MVC and PersistenceManager Closing
Hey , why do you want to close the persistance manager here, you are not saving or updating any entities. You should use a static PMF class to get the entity manager und you feed class should have something like this ... class FEED { private static PersistenceManager pm; // this fetches the persistance manager when u need it. private static PersistenceManager getPM() { if (pm == null) { pm = PMF.get().getPersistenceManager(); } else if (pm.isClosed()) { pm = PMF.get().getPersistenceManager(); } return pm; } @SuppressWarnings(unchecked) public static ListFEED getAll() { PersistenceManager pm = getPM(); String sqlFetch = SELECT FROM + FEED.class.getName(); Query query = pm.newQuery(sqlFetch); query.setOrdering(name asc); query.setRange(0, 50); ListFEED feeds = (ListFEED)query.execute(); return feeds; } Convinienty in your handleRequestInternal calss u can get the results - ListFeed feeds = FEEDS.getAll(); -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.