db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thoralf Rickert" <thoralf.rick...@cadooz.de>
Subject Mapping column types
Date Fri, 23 Dec 2005 14:33:23 GMT
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


Mime
View raw message