Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 56814 invoked from network); 22 Aug 2006 15:33:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Aug 2006 15:33:27 -0000 Received: (qmail 13924 invoked by uid 500); 22 Aug 2006 15:33:25 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 13910 invoked by uid 500); 22 Aug 2006 15:33:24 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 13899 invoked by uid 99); 22 Aug 2006 15:33:24 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 08:33:24 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: unknown mxptrmx:gateway.kewill.comip4:131.239.38.48ip4:131.239.38.78ip4:131.239.38.79-all (asf.osuosl.org: encountered unrecognized mechanism during SPF processing of domain of sourav.sen@kewill.com) Received: from [194.74.158.13] (HELO endor.KEWILL-EUROPE.COM) (194.74.158.13) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 08:33:22 -0700 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C6C600.3F5679F9" X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: RE: ---- Re: null pointer exception when updating sqlMap Date: Tue, 22 Aug 2006 16:32:59 +0100 Message-ID: <63F7A21F1CA18143AFDBF28E2A7D6BBA035CE0A0@endor.kewill-europe.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ---- Re: null pointer exception when updating sqlMap Thread-Index: AcbF/hT1i+t7wbdER7KZlVoihs6uAgAAYeXw From: "Sourav Sen" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C6C600.3F5679F9 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi ,=20 =20 A normal Javabean with a no-args public constructor and loads of getters and setters. There must be a way to tell iBatis to ignore nulls=20 =20 public class Pkg { =20 private Long pkgId; private String pkgNum; private Long mnfId; private Long cgnId; private BigDecimal pkgWeightKg; private BigDecimal pkgWeightLb; private BigDecimal pkgVolumeM3; private BigDecimal pkgVolumeC3; private BigDecimal pkgValue; =20 =20 public Pkg() { super(); setPkgId(Utils.getNextID()); setStateId(Constants.STATUS_SHIP_REQ_PACKAGE); =20 } =20 /** * @return Long */ public Long getCgnId() { return cgnId; } /** * @param cgnId */ public void setCgnId(Long cgnId) { this.cgnId =3D cgnId; } ... ... =20 } =20 Cheers sourav _____ =20 From: Adediran.Ayandele@Sun.COM [mailto:Adediran.Ayandele@Sun.COM]=20 Sent: 22 August 2006 16:17 To: user-java@ibatis.apache.org Subject: ---- Re: null pointer exception when updating sqlMap =20 What does your Pkg look like? Sourav Sen wrote:=20 Hi,=20 =20 It gives me a NullPointerException when trying to update a record that I previously selected using iBatis SQLMap. When I selected the record it had some null columns , I set some of them to valid values , but during my update All the other null columns stays as it is .=20 =20 Then when I do updatePkg(pkg) =20 I execute delegate methods that roughly looks like=20 =20 try { return (ArrayList) sqlMap. queryForList ("getPkgListByConsignmentId ", cgnId); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } =20 Then I enumerate my Pkgs and make some changes based on the context. Finally I try to update each one with another method that looks like =20 try { sqlMap.update("updatePkg", pkg); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } =20 Which uses select * from kse_pkg where CGN_ID =3D #cgnId# =20 UPDATE kse_pkg set pkg_num =3D #pkgNum#, mnf_id =3D #mnfId#, cgn_id =3D#cgnId#, pkg_weight_kg =3D #pkgWeightKg#, num_order =3D #numOrder#, pkg_trk_ref_num =3D #pkgTrkRefNum# , state_id =3D #stateId#, last_modified_by =3D #lastModifiedBy#, last_modified_date =3D #lastModifiedDate# WHERE pkg_id =3D #pkgId# =20 =20 Here if any of the fields like pkgTrkRefNum is null . I get a NullPointerException. =20 I get the same result if I select the same row using=20 =20 Any clues ? =20 Cheers sourav =20 =20 ------_=_NextPart_001_01C6C600.3F5679F9 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi ,

 

A normal Javabean with a no-args = public constructor and loads of getters and setters. There must be a way to = tell iBatis to ignore nulls

 

public class Pkg = {

 

      =       private Long = pkgId;

      =       private String = pkgNum;

      =       private Long = mnfId;

      =       private Long = cgnId;

      =       private BigDecimal pkgWeightKg;

      =       private BigDecimal pkgWeightLb;

      =       private BigDecimal pkgVolumeM3;

      =       private BigDecimal pkgVolumeC3;

      =       private BigDecimal = pkgValue;

 

 

public Pkg() = {

      =             &= nbsp;     super();

      =             &= nbsp;     = setPkgId(Utils.getNextID());

      =             &= nbsp;     = setStateId(Constants.STATUS_SHIP_REQ_PACKAGE);

      =             &= nbsp;    

      =       }

 

/**

      =        * @return = Long

      =        */

      =       public Long getCgnId() = {

      =             &= nbsp;     return cgnId;

      =       }

      =       /**

      =        * @param = cgnId

      =        */

      =       public void setCgnId(Long cgnId) {

      =             &= nbsp;     this.cgnId =3D cgnId;

      =       }

      =       …

      =       …

 

}

 

Cheers

sourav


From: Adediran.Ayandele@Sun.COM [mailto:Adediran.Ayandele@Sun.COM]
Sent: 22 August 2006 = 16:17
To: = user-java@ibatis.apache.org
Subject: ---- Re: null = pointer exception when updating sqlMap

 

What does your Pkg look like?

Sourav Sen wrote:

Hi,

 

It gives me a = NullPointerException when trying to update a record that I previously selected using iBatis = SQLMap.

When I selected the record = it had some null columns , I set some of them to valid values , but during my = update

All the other null columns = stays as it is .

 

Then when I do = updatePkg(pkg)

 

I execute delegate methods = that roughly looks like

 

try = {

    &nbs= p;       return (ArrayList) sqlMap. queryForList = ("getPkgListByConsignmentId ", = cgnId);

    &nbs= p;   } catch (SQLException e) {

    &nbs= p;       // TODO Auto-generated catch = block

    &nbs= p;       e.printStackTrace();

    &nbs= p;   }

 

Then I enumerate my Pkgs = and make some changes based on the context. Finally I try to update each one with another method that looks like

 

try = {

    &nbs= p;       sqlMap.update("updatePkg", = pkg);

    &nbs= p;   } catch (SQLException e) {

    &nbs= p;       // TODO Auto-generated catch = block

    &nbs= p;       e.printStackTrace();

    &nbs= p;   }

 

Which = uses

    &nbs= p;       <statement id=3D"getPkgListByConsignmentId" = parameterClass=3D"long"

       = ;     resultMap=3D"rMapPkgWithOrderItem">

       &= nbsp;    select * from kse_pkg where CGN_ID =3D = #cgnId#

      = </statement>

 

<update id=3D"updatePkg"

       = ;     parameterClass=3D"com.kse.vo.Pkg"<= /font>>

       &= nbsp;    UPDATE kse_pkg set pkg_num =3D #pkgNum#, mnf_id =3D #mnfId#, cgn_id = =3D#cgnId#, pkg_weight_kg =3D #pkgWeightKg#,

       &= nbsp;          num_order =3D #numOrder#, pkg_trk_ref_num =3D #pkgTrkRefNum# ,  = state_id =3D #stateId#,

       &= nbsp;          last_modified_by =3D #lastModifiedBy#, last_modified_date =3D = #lastModifiedDate#

       &= nbsp;          WHERE pkg_id =3D #pkgId#

      = </update>

 

<resultMap id=3D"rMapPkgWithOrderItem" = class=3D"com.kse.vo.Pkg"<= /font>>

       &= nbsp;    <result property=3D"mnfId" = column=3D"mnf_id" = />

       &= nbsp;    <result property=3D"pkgId" = column=3D"pkg_id" = />

       &= nbsp;    <result property=3D"cgnId" = column=3D"cgn_id" = />

       &= nbsp;    <result property=3D"pkgNum" = column=3D"pkg_num" = />

       &= nbsp;    <result property=3D"stateId" = column=3D"state_id" = />

       &= nbsp;    <result property=3D"pkgWeightKg" = column=3D"pkg_weight_kg" = />

       &= nbsp;    <result property=3D"pkgWeightLb" = column=3D"pkg_weight_lb" = />

       &= nbsp;    <result property=3D"pkgVolumeM3" = column=3D"pkg_volume_m3" = />

       &= nbsp;    <result property=3D"pkgVolumeC3" = column=3D"pkg_volume_c3" = />       &= nbsp;           &n= bsp; 

       &= nbsp;    <result property=3D"numOrder" = column=3D"num_order" = />

      = </resultMap>

 

Here if any of the = fields like pkgTrkRefNum is null  . I get a = NullPointerException.

 

 I = get the same result if I select  the same row using =

<select id=3D"getPkg" = parameterClass=3D"int"=

       = ;     resultClass=3D"com.kse.vo.Pkg"<= /font>>

       &= nbsp;    SELECT pkg_id,pkg_num,mnf_id,cgn_id,pkg_weight_kg as = pkgWeightKg,pkg_weight_lb as pkgWeightLb,

       &= nbsp;    pkg_volume_m3 as pkgVolumeM3 ,pkg_volume_c3 as = pkgVolumeC3,pkg_value,num_order,pkg_trk_ref_num as pkgTrkRefNum,

       &= nbsp;    picklist_flg,state_id,created_by,created_date,last_modified_date,last_mod= ified_by

       &= nbsp;    FROM kse_pkg WHERE pkg_id =3D = #pkgId#

      = </select>

 

Any clues = ?

 

Cheers

sourav

 

 

------_=_NextPart_001_01C6C600.3F5679F9--