Hi!
Fredrik Borgh wrote:
>
> > The null state problem has also been adressed. Here's the code:
> > if (((Integer)jdbcTypes.get(i)).intValue() == Types.REF)
> > {
> > if (((currentState[i] != null) &&
> > (oldState[i] == null ||
>!currentState[i].equals(oldState[i]))) ||
> > (oldState[i] != null))
>
> Won't the call to currentState[i].equals(oldState[i]) cause a
> NullPointerExcpetion if currentState[i] is null?? Since you've used the
> "or" ( || ), if currentState[i] is null, the first test in the if is not
> valid. Therefore it jumps to the second, which causes an Exception (or am
> I missing something??)
The equals will only be performed if currentState != null, since Java
shortcuts these kinds of expressions (i.e. if the first part is false,
and it's an &&, then skip the second expression). If they change place
(i.e. do the equals first), THEN it would break.
> > JawsCMPField[] pkFields = (JawsCMPField[])ejbRefs.get(refIdx);
> > for (int j = 0; j < pkFields.length; j++)
> > {
> > updateSql += (dirty?",":"") +
> >
>((JawsCMPField)CMPFields.get(i)).getColumnName()+"_"+pkFields[j].getColumnName()+"=?";
> > dirty = true;
> > }
> > dirtyField[i] = true;
> > }
> > refIdx++;
> > } else
> > {
> > if (((currentState[i] != null) &&
> > (oldState[i] == null || !currentState[i].equals(oldState[i]))) ||
> > (oldState[i] != null))
>
> Same here (se above).
Same as above.
It's in the details :-)
/Rickard
--
Rickard Öberg
@home: +46 13 177937
Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]