I'm trying to update a simple boolean value on a collection of objects
returned by a query.  The objects are being returned, and I set the
value on the bean, then persist, but it's not working. What am I
missing?

The Submission class has a "notifyAfter" as a Long (raw date), and an
"isNotified" Boolean.



        public void notifySubmissions( ){

                PersistenceManager pm = pmf.getPersistenceManager();

                Long rawDate = new Date().getTime() ;

            Query query = pm.newQuery(Submission.class);
            query.setFilter("rawDate >= notifyAfter && isNotified == false");

            query.declareParameters("Long rawDateParam");

            try {

                List<Submission> results = (List<Submission>)
query.execute( rawDate);


                if ( results.size() > 0 ) {
                        log.info(" " + results.size() + " results found");

                        Properties props = new Properties();
                        Session session = Session.getDefaultInstance(props, 
null);

                    for (Submission s : results) {

                        log.info("Emailing: " + s.getEmail());
                        Boolean mailed = true;

                                try {
                                    Message msg = new MimeMessage(session);
                                    msg.setFrom(new InternetAddress("...", 
"...") );

                                        msg.setText( ... );

                                    msg.addRecipient(Message.RecipientType.TO, 
new
InternetAddress(s.getEmail()));

                                    msg.setSubject("... Notification");


                                    Transport.send(msg);
                                    log.info("Mail sent to: " + s.getEmail());

                                } catch (AddressException ae) {
                                        log.warning( ae.getMessage() );
                                        mailed = false;
                                } catch (Exception e2) {
                                        mailed = false;
                                        log.warning( e2.getMessage() );
                                }

                                if (mailed){
                                        s.setIsNotified(true);
                                        pm.makePersistent( s );
                                }

                    }
                } else {
                   log.info("No results found");
                }
            } finally {
                query.closeAll();
            }

        }

-- 
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