ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Exception while setting properties
Date Wed, 16 Aug 2006 13:22:22 GMT
So does this make the error go away?

If the database allows null values, you really don't want to use an int -
and you are discovering why.

Even with JDK5 and auto-boxing, if you try to assign a null to an int, you
will get an NPE. So the only way around it is to assign a magic number (i.e.,
0) to mean null, which IMO is a retarded thing to do on purpose, but in some
cases is the only way.

Larry


On 8/16/06, Eugeny N Dzhurinsky <bofh@redwerk.com> wrote:
>
> On Mon, Aug 14, 2006 at 10:38:33AM -0600, Nathan Maves wrote:
> >
> >    what version of the jdk are you using?
> >    can you post the sqlmap as well as the set/get method of the property
> >    that you are having issues with?
>
>     <select id="loadTask" parameterClass="int" resultClass="
> com.project.Entity.Task">
>         select
>                 task_id,
>                 customer_id,
>                 monitor_id,
>                 status,
>                 created,
>                 start_time,
>                 stop_time,
>                 email,
>                 report_condition,
>                 track_domain,
>                 coalesce(use_banner,0) as use_banner,
>                 coalesce(use_robots,0) as use_robots,
>                 coalesce(use_cookies,0) as use_cookies,
>                 includes,
>                 excludes,
>                 redirects,
>                 error_codes,
>                 other
>         from task_scheduler
>             where task_id=#value#
>     </select>
>
> I added coalesce to avoid nulls
> setter method is:
>
> public void setUse_banner(int use_banner) {
>     this.use_banner = use_banner;
> }
>
> --
> Eugene N Dzhurinsky
>

Mime
View raw message