ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sourav Sen" <sourav....@kewill.com>
Subject RE: ---- Re: null pointer exception when updating sqlMap
Date Wed, 23 Aug 2006 09:13:01 GMT
Thanx Nathan. That worked. I mean using :#DATE#  in the update mapping
worked.

-----Original Message-----
From: Nathan Maves [mailto:nathan.maves@gmail.com] 
Sent: 22 August 2006 16:48
To: user-java@ibatis.apache.org
Subject: Re: ---- Re: null pointer exception when updating sqlMap

Do what I told you and it will call the correct setNull() for the
specific column.



On 8/22/06, Sourav Sen <sourav.sen@kewill.com> wrote:
>
>
>
>
> 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() {
>
>                         super();
>
>                         setPkgId(Utils.getNextID());
>
>
> setStateId(Constants.STATUS_SHIP_REQ_PACKAGE);
>
>
>
>             }
>
>
>
> /**
>
>              * @return Long
>
>              */
>
>             public Long getCgnId() {
>
>                         return cgnId;
>
>             }
>
>             /**
>
>              * @param cgnId
>
>              */
>
>             public void setCgnId(Long cgnId) {
>
>                         this.cgnId = 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 {
>
>             return (ArrayList) sqlMap. queryForList
> ("getPkgListByConsignmentId ", cgnId);
>
>         } catch (SQLException e) {
>
>             // TODO Auto-generated catch block
>
>             e.printStackTrace();
>
>         }
>
>
>
> 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 {
>
>             sqlMap.update("updatePkg", pkg);
>
>         } catch (SQLException e) {
>
>             // TODO Auto-generated catch block
>
>             e.printStackTrace();
>
>         }
>
>
>
> Which uses
>
>             <statement id="getPkgListByConsignmentId"
parameterClass="long"
>
>             resultMap="rMapPkgWithOrderItem">
>
>             select * from kse_pkg where CGN_ID = #cgnId#
>
>       </statement>
>
>
>
> <update id="updatePkg"
>
>             parameterClass="com.kse.vo.Pkg">
>
>             UPDATE kse_pkg set pkg_num = #pkgNum#, mnf_id = #mnfId#,
cgn_id
> =#cgnId#, pkg_weight_kg = #pkgWeightKg#,
>
>                   num_order = #numOrder#, pkg_trk_ref_num =
#pkgTrkRefNum# ,
>  state_id = #stateId#,
>
>                   last_modified_by = #lastModifiedBy#,
last_modified_date =
> #lastModifiedDate#
>
>                   WHERE pkg_id = #pkgId#
>
>       </update>
>
>
>
> <resultMap id="rMapPkgWithOrderItem" class="com.kse.vo.Pkg">
>
>             <result property="mnfId" column="mnf_id" />
>
>             <result property="pkgId" column="pkg_id" />
>
>             <result property="cgnId" column="cgn_id" />
>
>             <result property="pkgNum" column="pkg_num" />
>
>             <result property="stateId" column="state_id" />
>
>             <result property="pkgWeightKg" column="pkg_weight_kg" />
>
>             <result property="pkgWeightLb" column="pkg_weight_lb" />
>
>             <result property="pkgVolumeM3" column="pkg_volume_m3" />
>
>             <result property="pkgVolumeC3" column="pkg_volume_c3" />
>
>
>             <result property="numOrder" column="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="getPkg" parameterClass="int"
>
>             resultClass="com.kse.vo.Pkg">
>
>             SELECT
> pkg_id,pkg_num,mnf_id,cgn_id,pkg_weight_kg as
> pkgWeightKg,pkg_weight_lb as pkgWeightLb,
>
>             pkg_volume_m3 as pkgVolumeM3 ,pkg_volume_c3 as
> pkgVolumeC3,pkg_value,num_order,pkg_trk_ref_num as
> pkgTrkRefNum,
>
>
>
picklist_flg,state_id,created_by,created_date,last_modified_date,last_mo
dified_by
>
>             FROM kse_pkg WHERE pkg_id = #pkgId#
>
>       </select>
>
>
>
> Any clues ?
>
>
>
> Cheers
>
> sourav
>
>
>
>


Mime
View raw message