This is due to an error in the Postgres Driver. As Jboss writes it as an
Int but reads it as a boolean, it is written as a "1" or "0" but the
driver only accepts "t" or "T" when getting the resultset back as
boolean. An easy fix to this problem is to change the ResultSet.java
file in package org.postgresql.jdbc2 in the Postgres jdbc driver so the
function getBoolean(int columnIndex) reads as follows:
public boolean getBoolean(int columnIndex) throws SQLException
{
String s = getString(columnIndex);
if (s != null)
{
int c = s.charAt(0);
return ((c == 't') || (c == 'T') || (c == '1'));
}
return false; // SQL NULL
}
Thus adding support for handling 0's and 1's as well as the postgres
standard 't'.
This works with the current jaws mapping. And if i recall correctly it
doesnt work even if you try mapping jaws to use boolean without changing
and recompiling the postgres jdbc driver.
</christofer>
On 19 Jul 2001 05:04:35 -0700, nathan frund wrote:
> Hermann,
>
> I'm running PostgreSQL 7.1.2 with JBoss 2.2.2 with
> sucess of CMP beans creating tables upon deployment
> but I too have had difficulty with the Boolean
> datatype. I've gotten it to insert and update 1 for
> true and 0 for false but when the server (JBoss) is
> restarted it writes all boolean fields acted upon back
> to false. I haven't tried mapping the datatype in
> JAWS to bool yet, as I'm working on other parts of the
> project. I may try today. If I works I'll be sure to
> let you know.
>
>
> --- Hermann RANGAMANA <[EMAIL PROTECTED]>
> wrote:
> > Hi all,
> >
> > i'm currently using jBoss 2.2.1 and postgreSQL
> > 7.0.1. I deploy my bean as
> > CMP but when i try to create one, the database
> > throws error back :
> >
> > ERROR: Attribute 'valide' is of type 'bool' but
> > expression is of type
> > 'int4'
> >
> > valide is a field in the bean : type boolean
> > valide is also a column in the table with BOOLEAN
> > type
> >
> > in standardjaws.xml data mapping of postgresSQL, i
> > found this :
> >
> > <mapping>
> > <java-type>java.lang.Boolean</java-type>
> > <jdbc-type>TINYINT</jdbc-type>
> > <sql-type>INT2</sql-type>
> > </mapping>
> >
> > that is jBoss maps java primitive type boolean into
> > pgsql type int2, so
> > value 'true' is inserted as 0 and value 'false'- i
> > don't know. But it fails!
> >
> > Since pgsql has a 'BOOLEAN' type, why map
> > java.lang.Boolean to INT2 instead
> > of directly BOOLEAN? My guess is that, when jaws
> > prepare the
> > PreparedStatement for inserting a boolean value, it
> > uses setInt () (because
> > of type mapping to TINYINT) instead of setBoolean
> > (). And then comes the
> > exception ....
> >
> > Has anyone faced this problem ?
> >
> > Reguards.
> >
> > --hermann
> >
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> >
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user