Обсуждение: issue with integer nullable column and value 0

Поиск
Список
Период
Сортировка

issue with integer nullable column and value 0

От
Sean Hsien
Дата:
Hi guys,

I'm not sure what the source of this bug is, as I'm getting a
discrepancy between 8.1 on Linux vs. 8.4 on Windows, using the latest
JDBC driver type 4.

The issue is this, I have a nullable integer column in one of my
tables. When I'm updating the column in 8.4 Windows with value 0, it
stays as null, but on the Linux 8.1 it will try to update it with the
value 0.

Not sure if anyone else has come across this issue?

Thanks in advance.

Sean

Re: issue with integer nullable column and value 0

От
"Kevin Grittner"
Дата:
Sean Hsien <umphy27@gmail.com> wrote:

> using the latest JDBC driver type 4.

> I have a nullable integer column in one of my tables. When I'm
> updating the column in 8.4 Windows with value 0, it stays as null,
> but on the Linux 8.1 it will try to update it with the value 0.

Could you post a small, self-contained example of code which exhibits
this problem?  Also, what are the OS and Java versions on the client
side?

-Kevin

Re: issue with integer nullable column and value 0

От
Sean Hsien
Дата:
I'm using CentOS 5.2 64-bits with postgres 8.1.11 + java 6u16, and
Windows Vista 32-bits with postgres 8.4.1 + java 6u13.

Here is a small code snippet that shows the problem, where the user id
value is 0:

    public void update(EntityVO vo) {
        StringBuilder sql =3D new StringBuilder();
        sql.append("UPDATE nvt_entity" +
                " SET user_id =3D ?" +
                " WHERE entity_id =3D ?");

        Object args[] =3D {
            vo.getUserId() =3D=3D -1 ? null : vo.getUserId(),
            vo.getEntityId()
        };

        getJdbcTemplate().update(sql.toString(), args);
    }

Thanks for your time.

2009/10/15 Kevin Grittner <Kevin.Grittner@wicourts.gov>:
> Sean Hsien <umphy27@gmail.com> wrote:
>
>> using the latest JDBC driver type 4.
>
>> I have a nullable integer column in one of my tables. When I'm
>> updating the column in 8.4 Windows with value 0, it stays as null,
>> but on the Linux 8.1 it will try to update it with the value 0.
>
> Could you post a small, self-contained example of code which exhibits
> this problem? =C2=A0Also, what are the OS and Java versions on the client
> side?
>
> -Kevin
>

Re: issue with integer nullable column and value 0

От
"Kevin Grittner"
Дата:
Sean Hsien <umphy27@gmail.com> wrote:
> 2009/10/15 Kevin Grittner <Kevin.Grittner@wicourts.gov>:

>> what are the OS and Java versions on the client side?

> I'm using CentOS 5.2 64-bits with postgres 8.1.11 + java 6u16, and
> Windows Vista 32-bits with postgres 8.4.1 + java 6u13.

So the Java code is running on the same machine as the database in
each case?

>> Could you post a small, self-contained example of code which
>> exhibits this problem?

> Here is a small code snippet

A self-contained example would include creation and population of the
table, as well as enough code to actually run the snippet and show the
results.  You should run this in both environments to confirm that the
problem indeed manifests as you describe with the example you provide.

-Kevin

Re: issue with integer nullable column and value 0

От
Sean Hsien
Дата:
Found the bug...was my fault, of course.

Sorry for the mistake.

Sean