You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Thoralf Rickert <th...@cadooz.de> on 2005/12/23 15:33:23 UTC

Mapping column types

Hi!

I'm switching currently from Torque 3.1 to 3.2 and have a problem with
the column type boolean. I'm using MySQL 5.0.16 and the mysql connector
3.1.12. The table type is InnoDB.

I've a table which contains a boolean, like this:

<database name="test" defaultIdMethod="native" defaultJavaType="object">
 <table name="test">
   <column name="id" required="true" type="BIGINT" primaryKey="true"
autoIncrement="true"/>
   <column name="myBool" required="true" type="BIT" default="0"/>
 </table>
</database>

The generated SQL syntax for the insert-sql task contains this:

CREATE TABLE test
(
    id BIGINT NOT NULL AUTO_INCREMENT,
    myBool BIT default 0 NOT NULL,
    PRIMARY KEY(id)
) Type=InnoDB ;

The database accepts this syntax, but when I create a Test object and
save it to the database the boolean flag is always false. 

  test = new Test();
  test.setMybool(new Boolean(false));
  test.save();

I'm not sure, if this is a Torque problem, because the BIT feature is
new to MySQL and there was at least one bug about it, that I've
reported. But my workaround in Torque 3.1 was it to change the mapping
from Java objects to MySQL types by editing the db.props in templates.
There I've changed the BIT to TINYINT and everything was fine.

Now in Torque 3.2 it seems to me, that this db.props file is no longer
supported. Is this correct? Why? And what can I do to get Java boolean
Object but a MySQL tinyint?

The db.props also contains the table type (here InnoDB) settings. Where
can I set the table type in Torque 3.2 now?

Bye
Thoralf





---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Mapping column types

Posted by Αντώνης Λεμπέσης <an...@di.uoa.gr>.
Thoralf Rickert wrote:

>Hi!
>
>I'm switching currently from Torque 3.1 to 3.2 and have a problem with
>the column type boolean. I'm using MySQL 5.0.16 and the mysql connector
>3.1.12. The table type is InnoDB.
>
>I've a table which contains a boolean, like this:
>
><database name="test" defaultIdMethod="native" defaultJavaType="object">
> <table name="test">
>   <column name="id" required="true" type="BIGINT" primaryKey="true"
>autoIncrement="true"/>
>   <column name="myBool" required="true" type="BIT" default="0"/>
> </table>
></database>
>
>The generated SQL syntax for the insert-sql task contains this:
>
>CREATE TABLE test
>(
>    id BIGINT NOT NULL AUTO_INCREMENT,
>    myBool BIT default 0 NOT NULL,
>    PRIMARY KEY(id)
>) Type=InnoDB ;
>
>The database accepts this syntax, but when I create a Test object and
>save it to the database the boolean flag is always false. 
>
>  test = new Test();
>  test.setMybool(new Boolean(false));
>  test.save();
>
>I'm not sure, if this is a Torque problem, because the BIT feature is
>new to MySQL and there was at least one bug about it, that I've
>reported. But my workaround in Torque 3.1 was it to change the mapping
>from Java objects to MySQL types by editing the db.props in templates.
>There I've changed the BIT to TINYINT and everything was fine.
>
>Now in Torque 3.2 it seems to me, that this db.props file is no longer
>supported. Is this correct? Why? And what can I do to get Java boolean
>Object but a MySQL tinyint?
>
>The db.props also contains the table type (here InnoDB) settings. Where
>can I set the table type in Torque 3.2 now?
>
>Bye
>Thoralf
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>
>  
>
Hi,

  I have the exact same problem. After some debugging, I found out that 
the problem lies on the way village translates the output of the jdbc 
driver. The drivers returns an integer for the fields of type bit (1 for 
true, 0 for false). Village obviously (I don't have the source code) 
tries to parse the int value using the method 
Boolean.parseBoolean(int[], int, int), which returns false in either case...
After a brief search, I wasn't able to find the source code and see If I 
could create a simple patch.

Antonis

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Mapping column types

Posted by an...@di.uoa.gr.
  The same bug exists in both version 3.1.7 which I used for mysql4, and 3.1.12,
the latest version.

  Even if there was a special driver for mysql4, the same problem would exist,
since the BIT type is new in mysql. If the latest driver does not understand it
, why would the old one do???

Antonis

Thomas Fischer wrote <fi...@seitenbau.net>:

> 
> 
> 
> 
> Hm, not easy to work with buggy drivers...
> 
> Just a crazy idea: Is it possible to use a mysql4 driver for a mysql5
> database ?
> 
>     Thomas
> 
> antleb@di.uoa.gr schrieb am 28.12.2005 20:45:08:
> 
> > Thomas Fischer wrote <fi...@seitenbau.net>:
> >
> > >
> > >
> > >
> > >
> > > Hi,
> > >
> > > The property files were converted into java classes. They are located
> in
> > > the subpackage "platform" of the generator.
> > >
> > > From your mail, it seems that the behaviour of the mysql driver changed
> > > from mysql4 to mysql5.If I remember correctly, the bit type worked
> > > correctly for mysql4 (I used the test project to check this, there is a
> > > test case for bit in there).  I'll try to check the bit type against
> mysql5
> > > in the next days.
> > >
> > > As a workaraound, you can use the booleanint or booleanchar types.
> > >
> > >     Thomas
> > >
> >
> > Hi,
> >   I looked into the problem and the problem lies on a bug of jdbc
> connector
> > (org.gjt.mm.mysql.Driver). It reports the type of BIT fields to be
> > 12 instead of
> > -7 (java.sql.Types).
> >   I checked the bug list of MySQL: the bug has already been reported and
> a
> > couple of solutions have been commited. The correction will be available
> with
> > the new release. Until then, I'm thinking of "patching" the source code
> of
> > Village (com.workingdogs.village.Column.populate(ResultSetMetaData rsmd,
> int
> > colNum, String tableName)), but I'm not sure that this is the only method
> that
> > uses the buggy code.
> >
> > Antonis
> >
> > --
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 


-- 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Mapping column types

Posted by Thomas Fischer <fi...@seitenbau.net>.



Hm, not easy to work with buggy drivers...

Just a crazy idea: Is it possible to use a mysql4 driver for a mysql5
database ?

    Thomas

antleb@di.uoa.gr schrieb am 28.12.2005 20:45:08:

> Thomas Fischer wrote <fi...@seitenbau.net>:
>
> >
> >
> >
> >
> > Hi,
> >
> > The property files were converted into java classes. They are located
in
> > the subpackage "platform" of the generator.
> >
> > From your mail, it seems that the behaviour of the mysql driver changed
> > from mysql4 to mysql5.If I remember correctly, the bit type worked
> > correctly for mysql4 (I used the test project to check this, there is a
> > test case for bit in there).  I'll try to check the bit type against
mysql5
> > in the next days.
> >
> > As a workaraound, you can use the booleanint or booleanchar types.
> >
> >     Thomas
> >
>
> Hi,
>   I looked into the problem and the problem lies on a bug of jdbc
connector
> (org.gjt.mm.mysql.Driver). It reports the type of BIT fields to be
> 12 instead of
> -7 (java.sql.Types).
>   I checked the bug list of MySQL: the bug has already been reported and
a
> couple of solutions have been commited. The correction will be available
with
> the new release. Until then, I'm thinking of "patching" the source code
of
> Village (com.workingdogs.village.Column.populate(ResultSetMetaData rsmd,
int
> colNum, String tableName)), but I'm not sure that this is the only method
that
> uses the buggy code.
>
> Antonis
>
> --
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Mapping column types

Posted by an...@di.uoa.gr.
Thomas Fischer wrote <fi...@seitenbau.net>:

> 
> 
> 
> 
> Hi,
> 
> The property files were converted into java classes. They are located in
> the subpackage "platform" of the generator.
> 
> From your mail, it seems that the behaviour of the mysql driver changed
> from mysql4 to mysql5.If I remember correctly, the bit type worked
> correctly for mysql4 (I used the test project to check this, there is a
> test case for bit in there).  I'll try to check the bit type against mysql5
> in the next days.
> 
> As a workaraound, you can use the booleanint or booleanchar types.
> 
>     Thomas
> 

Hi,
  I looked into the problem and the problem lies on a bug of jdbc connector
(org.gjt.mm.mysql.Driver). It reports the type of BIT fields to be 12 instead of
-7 (java.sql.Types). 
  I checked the bug list of MySQL: the bug has already been reported and a
couple of solutions have been commited. The correction will be available with
the new release. Until then, I'm thinking of "patching" the source code of
Village (com.workingdogs.village.Column.populate(ResultSetMetaData rsmd, int
colNum, String tableName)), but I'm not sure that this is the only method that
uses the buggy code.

Antonis

-- 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Mapping column types

Posted by Thomas Fischer <fi...@seitenbau.net>.



Hi,

The property files were converted into java classes. They are located in
the subpackage "platform" of the generator.

>From your mail, it seems that the behaviour of the mysql driver changed
from mysql4 to mysql5.If I remember correctly, the bit type worked
correctly for mysql4 (I used the test project to check this, there is a
test case for bit in there).  I'll try to check the bit type against mysql5
in the next days.

As a workaraound, you can use the booleanint or booleanchar types.

    Thomas

"Thoralf Rickert" <th...@cadooz.de> schrieb am 23.12.2005
15:33:23:

> Hi!
>
> I'm switching currently from Torque 3.1 to 3.2 and have a problem with
> the column type boolean. I'm using MySQL 5.0.16 and the mysql connector
> 3.1.12. The table type is InnoDB.
>
> I've a table which contains a boolean, like this:
>
> <database name="test" defaultIdMethod="native" defaultJavaType="object">
>  <table name="test">
>    <column name="id" required="true" type="BIGINT" primaryKey="true"
> autoIncrement="true"/>
>    <column name="myBool" required="true" type="BIT" default="0"/>
>  </table>
> </database>
>
> The generated SQL syntax for the insert-sql task contains this:
>
> CREATE TABLE test
> (
>     id BIGINT NOT NULL AUTO_INCREMENT,
>     myBool BIT default 0 NOT NULL,
>     PRIMARY KEY(id)
> ) Type=InnoDB ;
>
> The database accepts this syntax, but when I create a Test object and
> save it to the database the boolean flag is always false.
>
>   test = new Test();
>   test.setMybool(new Boolean(false));
>   test.save();
>
> I'm not sure, if this is a Torque problem, because the BIT feature is
> new to MySQL and there was at least one bug about it, that I've
> reported. But my workaround in Torque 3.1 was it to change the mapping
> from Java objects to MySQL types by editing the db.props in templates.
> There I've changed the BIT to TINYINT and everything was fine.
>
> Now in Torque 3.2 it seems to me, that this db.props file is no longer
> supported. Is this correct? Why? And what can I do to get Java boolean
> Object but a MySQL tinyint?
>
> The db.props also contains the table type (here InnoDB) settings. Where
> can I set the table type in Torque 3.2 now?
>
> Bye
> Thoralf
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org