NullPointerException using inline parameter mappings

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

NullPointerException using inline parameter mappings

gunnlaugursig
Hello,

I'm still struggling to get one of my selects working.

In my xml mapper I have the following selects,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="is.simnn.act.web.ngs.mappers.UserInfoMapper">
        <select id="getUserInfoBySnb" parameterType="is.simnn.act.web.ngs.domain.UserInfo" resultType="userInfo">
                SELECT
                        port.snb,
                        port.timestamp_,
                        port.user_type,
                        port.real_exch,
                        port.act_exch,
                        port.dev_type,
                        port.rc
                FROM
                        port
                WHERE
                        port.snb = #{snb}
        </select>

        <select id="getAllUserInfoBySnb" parameterType="is.simnn.act.web.ngs.domain.UserInfo" resultType="userInfo">
                SELECT
                        p.snb,
                        p.real_exch,
                        p.act_exch,
                        p.user_type,
                        p.dev_type,
                        p.dev_number,
                        p.main_number,
                        p.ea_int,
                        p.ea_nat,
                        p.TIMESTAMP_,
                        p.timestamp_comp,
                        p.rc,
                        p.bsnb,
                        p.black,
                        p.out_go_num,
                        p.imsi,
                        p.subscr_type,
                        p.dual_main,
                        p.dual_sec,
                        p.sec_exchange,
                        p.special_scl,
                        p.name_of_user,
                        p.status_id,
                        p.category_id,
                        p.head_number,
                        p.status_id_tstamp,
                        ngs.subscr_subtype
                FROM
                        port p inner join ngs_add_data ngs
                                ON ngs.snb = p.snb
                WHERE
                        p.snb = #{snb}
        </select>

        <select id="getUserInfoByImsi" parameterType="is.simnn.act.web.ngs.domain.UserInfo" resultType="userInfo">
                SELECT
                        port.snb,
                        port.timestamp_,
                        port.user_type,
                        port.real_exch,
                        port.act_exch,
                        port.dev_type,
                        port.rc
                FROM
                        port
                WHERE
                        port.imsi = #{imsi} AND port.status_id = #{status_id}
        </select>
</mapper>

For some reason the last of three selects constantly returns NullPointerException.
If I run the select using SQL Developer it works fine.

Any idea what I might be doing wrong here?

Thanks
Gunnlaugur
Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException using inline parameter mappings

gunnlaugursig
My problem is realated to this part,
port.imsi = #{imsi} AND port.status_id = #{status_id}

If I run it like this it works,
port.imsi = '1234567' AND port.status_id = 1

I have also tried it like this with no luck,
port.imsi = #{imsi, jdbcType=CHAR} AND port.status_id = #{status_id, jdbcType=NUMERIC}

Any idea what might cause my problem?

Thanks,
Gunnlaugur
Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException using inline parameter mappings

Jackie Li
Hi,

Have you checked the log, and make sure the passed in object "is.simnn.act.
web.ngs.domain.UserInfo" not null?

Cheers,
Jackie


On Tue, May 24, 2011 at 20:56, gunnlaugursig <[hidden email]> wrote:
My problem is realated to this part,
port.imsi = #{imsi} AND port.status_id = #{status_id}

If I run it like this it works,
port.imsi = '1234567' AND port.status_id = 1

I have also tried it like this with no luck,
port.imsi = #{imsi, jdbcType=CHAR} AND port.status_id = #{status_id,
jdbcType=NUMERIC}

Any idea what might cause my problem?

Thanks,
Gunnlaugur

--
View this message in context: http://mybatis-user.963551.n3.nabble.com/NullPointerException-using-inline-parameter-mappings-tp2961928p2979557.html
Sent from the mybatis-user mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException using inline parameter mappings

Marcelo Olivas
In reply to this post by gunnlaugursig
Are you passing the right parameterType or parameterMap? 

On Tue, May 24, 2011 at 8:56 AM, gunnlaugursig <[hidden email]> wrote:
My problem is realated to this part,
port.imsi = #{imsi} AND port.status_id = #{status_id}

If I run it like this it works,
port.imsi = '1234567' AND port.status_id = 1

I have also tried it like this with no luck,
port.imsi = #{imsi, jdbcType=CHAR} AND port.status_id = #{status_id,
jdbcType=NUMERIC}

Any idea what might cause my problem?

Thanks,
Gunnlaugur

--
View this message in context: http://mybatis-user.963551.n3.nabble.com/NullPointerException-using-inline-parameter-mappings-tp2961928p2979557.html
Sent from the mybatis-user mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException using inline parameter mappings

gunnlaugursig
I resolved the issue using ${value} instead of #{value}
Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException using inline parameter mappings

Jackie Li
I roughly remember for some version of mybatis, ${value} is supported
only. And both works for latter version, however, meaning different .

On May 25, 4:11 pm, gunnlaugursig <[hidden email]> wrote:
> I resolved the issue using ${value} instead of #{value}
>
> --
> View this message in context:http://mybatis-user.963551.n3.nabble.com/NullPointerException-using-i...
> Sent from the mybatis-user mailing list archive at Nabble.com.