Re: NullPointerException

From: Gowry Gabriev (gowry.gabrie..mail.com)
Date: Tue Aug 17 2004 - 13:15:27 EDT

  • Next message: Mike Kienenberger: "Re: NullPointerException"

    I modified UpdateBatchQueryBuilder createSqlString to ignore null
    dbattribute entries, and it seems to be working for me so far. I tried
    to find the previous versions on sourceforge cvs to see if it'd changed
    recently but the file didn't exist there.

       public String createSqlString(BatchQuery batch) {
            UpdateBatchQuery updateBatch = (UpdateBatchQuery) batch;
            String table = batch.getDbEntity().getFullyQualifiedName();
            List qualifierAttributes = updateBatch.getQualifierAttributes();
            List updatedDbAttributes = updateBatch.getUpdatedAttributes();

            StringBuffer query = new StringBuffer("UPDATE ");
            query.append(table).append(" SET ");

            int len = updatedDbAttributes.size();
            for (int i = 0; i < len; i++) {
                    if(updatedDbAttributes.get(i)!=null) {
                       if (i > 0) {
                           query.append(", ");
                       }

                       DbAttribute attribute = (DbAttribute)
    updatedDbAttributes.get(i);
                          query.append(attribute.getName()).append(" = ?");
                    }
            }

            query.append(" WHERE ");

            Iterator i = qualifierAttributes.iterator();
            while (i.hasNext()) {
                DbAttribute attribute = (DbAttribute) i.next();
                appendDbAttribute(query, attribute);
                query.append(updateBatch.isNull(attribute) ? " IS NULL" : " = ?");

                if (i.hasNext()) {
                    query.append(" AND ");
                }
            }

            return query.toString();
        }

    On Tue, 17 Aug 2004 10:54:45 -0400, Mike Kienenberger
    <mkienen..laska.net> wrote:
    > It's also possible it's related to optimistic locking, for which I did the
    > peliminary code in UpdateBatchQueryBuilder back in M3/M4/M5. Unfortunately,
    > I didn't see the original message, only the message that Andrus responded
    > to.
    >
    > I was unable to grab 1.1b2 from cvs yesterday, but I'll try again today and
    > see if anything is obviously wrong to me.
    >
    > Please open a support case and attach any relevant information, including
    > stack traces and your use of optimistic locking.
    >
    > Thanks!
    >
    > -Mike
    >
    >
    >
    >
    > Gary Jarrel <garyjarre..rownbilljarrel.com.au> wrote:
    > > It's quite interesting that somebody mentioned this issue cause I'm
    > getting
    > > an exactly the same problem with 1.1B2 over the last few days. I haven't
    > > tested with a previous beta version.
    > >
    > > But now that Andrus mentioned some interesting facts about the db
    > > relationships I might start looking from that angle a bit closer.
    > >
    > > Whats funny, was that I thought it was my SQL server driver issue, as I
    > was
    > > using the MS jdbc driver. I've switched to using the jdts driver and it
    > > worked once ok but then started throwing the exception again. Hmm will
    > keep
    > > looking.
    > >
    > > - Gary
    > >
    > > -----Original Message-----
    > > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > > Sent: Monday, August 16, 2004 7:10 PM
    > > To: cayenne-use..bjectstyle.org
    > > Subject: Re: NullPointerException
    > >
    > > Hmm, that's strange. Could you submit a bug report
    > > (http://objectstyle.org/cayenne/bugs-features.html), attaching your data
    > > map and sample code.
    > >
    > > A random question - when you save your project in the modeler, do you get
    > > any warnings?
    > >
    > > P.S. As I am still on vacation, I won't be able to do any real work on
    > > that till the end of August.
    > >
    > > > I'm getting a NullPointerException when I'm running a program.
    > > > It occurs on line 97 of UpdateBatchQueryBuilder in 1.1B2.
    > > >
    > > > I looked at the data structures in a debugger, and it has 7
    > > > null DbAttribute objects that it's attempting to do an update for.
    > > >
    > > > Have I done something wrong in my code or is there a bug here?
    > > >
    > > > Thanks!
    > > >
    > > > Gowry
    > >
    > >
    > >
    > >
    > >
    > >
    >



    This archive was generated by hypermail 2.0.0 : Tue Aug 17 2004 - 13:15:28 EDT