Hi

I just wanted to confirm that I am using the PersistenceManager in the
correct manner...  I have a List of a JDO persisted class retrieved in
my Spring MVC controller as follows:

protected ModelAndView handleRequestInternal(HttpServletRequest req,
HttpServletResponse resp) throws Exception {

                PersistenceManager pm =
PersistenceHelper.getPersistenceManagerFactory().getPersistenceManager
();
                String query = "select from " + Feed.class.getName() + " order 
by
lastNewItem desc";
                List<Feed> feeds = (List<Feed>)pm.newQuery(query).execute();

                pm.retrieveAll(feeds);

                pm.close();

                ModelAndView mv = new ModelAndView();
                mv.addObject("feedList", DataUtil.getFeeds());
                mv.setViewName("feeds");
                return mv;
        }

This is passing the List of Feed objects to the view which iterates
through and displays each.  My problem is that I need to close the
PersistenceManager in this method and unless I use the pm.retrieveAll
() method, I get an org.datanucleus.exceptions.NucleusUserException:
Object Manager has been closed error.

My problem is that I don't need to load ALL of the fields in the Feed
class... in particular it owns a 1:M relationship to FeedItem and I
would rather not load all of these as well.

I have tried annotating this field in my Feed class as follows:

@Persistent(mappedBy = "feed", defaultFetchGroup="false")
private List<FeedItem> items;

... but they all get loaded anyway.

Is there any way to configure this?  Alternatively, I could choose not
to close the PersistenceManager but I assume this is expensive and bad
practice?


Thanks in advance
Al.

--

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.


Reply via email to