Re: Issue with the cache

From: Joshua Pyle (joshua.t.pyl..mail.com)
Date: Tue Feb 15 2005 - 14:05:56 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: Multiple DataNodes"

    I found the issue. Its not directly a cayenne issue, but it may be
    related to cayenne. I use my Cayenne object to create and send an
    email message the issue was with the content of the message. No
    matter what I did to the DB the mail message did not change. Here is
    an example prior to my fix...

    public class Maildata extends _Maildata {

        protected MimeMessage mimeMessage = null;

        public void assemble(String smtpHost) throws MessagingException {

            Properties properties = System.getProperties();
            properties.put("mail.smtp.host", smtpHost);
            Session session = Session.getInstance(properties, null);

            try {
                mimeMessage = new MimeMessage(session);

                mimeMessage.setFrom(new InternetAddress(getMailFrom()));

                ...

                mimeMessage.setContent(mp);

            } catch (MessagingException e) {
                mimeMessage = null;
                throw (MessagingException) e.fillInStackTrace();
            }

        }

        public void send(String smtpHost) throws MessagingException {
            if (mimeMessage == null) {
                assemble(smtpHost);
            }
            Transport.send(mimeMessage);
        }

    }

    Here are my fixes. This works...

    public class Maildata extends _Maildata {

        protected MimeMessage mimeMessage = null;

        public MimeMessage assemble(String smtpHost) throws MessagingException {

            MimeMessage mimeMessage = null;
            Properties properties = System.getProperties();
            properties.put("mail.smtp.host", smtpHost);
            Session session = Session.getInstance(properties, null);

            try {
                mimeMessage = new MimeMessage(session);

                mimeMessage.setFrom(new InternetAddress(getMailFrom()));

                ...

                mimeMessage.setContent(mp);

            } catch (MessagingException e) {
                mimeMessage = null;
                throw (MessagingException) e.fillInStackTrace();
            }
            return mimeMessage;

        }

        public void send(String smtpHost) throws MessagingException {
            Transport.send(assemble(smtpHost));
        }

    }

    Thee is either something very, very weird going on with cayenne or the
    mimeMessage is doing something very weird.

    -- 
    Joshua T. Pyle
    Go has always existed.
    

    On Mon, 14 Feb 2005 23:27:50 -0500, Andrus Adamchik <andru..bjectstyle.org> wrote: > > On Feb 14, 2005, at 10:45 PM, Joshua Pyle wrote: > > I'm running into an interesting problem... > > > > 1. I run a query in Cayenne > > 2. Outside of chayenne I update a field and commit to the DB > > 3. I re-run the test at 1 and the field has not changed. > > > > I'm using Oracle 9 DB and jdbc drivers > > I have turned off shared cache > > I'm running from within a TimerTask that uses a thread bound > > datacontext > > > I call the following before re-running the query ... > > dbContext.invalidateObjects( > > dbContext.getObjectStore().getObjects() ); > > This is not needed if you want to refresh *root* objects of this query. > To refresh objects *related* to the root objects you can set query > prefetching. Also if you use a query stored in the DataMap, make sure > "Refresh Results" checkbox is checked, and of course "No Result > Caching" is selected. > > BTW, instead of invalidating *all* objects you can just throw away a > given DataContext instance and create a new one. This is an equivalent > operation, but looks much cleaner. > > > This is a bit frustrating because it seems to only hold onto varchar > > fields, when I change a DATE field the change of the DATE field is > > noticed but not the varchar field changes. > > This doesn't sound right. As far as caching is concerned Cayenne > doesn't care about attribute types. There has to be something else at > play. Can you create a test case demonstrating it? > > Andrus > >



    This archive was generated by hypermail 2.0.0 : Tue Feb 15 2005 - 14:05:58 EST