[ 
https://issues.apache.org/jira/browse/IBATIS-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501229
 ] 

Andrea Pantaleoni commented on IBATIS-434:
------------------------------------------

Jeff my goal it is just to contribute to open source software

I tried mysql jdbc driver mysql-connector-java-5.0.3-bin.jar
 with the following code
                                                                
Class.forName("com.mysql.jdbc.Driver");
                        String url ="jdbc:mysql://localhost:3311/test";
                        Connection con =DriverManager.getConnection(url,"root", 
"menem");
                        Statement stmt = con.createStatement();
                        ResultSet rs = stmt.executeQuery("SELECT id FROM BUG");
                        ResultSetMetaData rsmd = rs.getMetaData();
                        System.out.println(rsmd.getColumnType(1));

if I define the column id as tinyint(4) I get -6 which is java.sql.Types.TINYINT
if I define the column id as tinyint(1) I get -7 which is java.sql.Types.BIT

in the abator source code the class JavaTypeResolverDefaultImpl

is written in the method public void 
initializeResolvedJavaType(ColumnDefinition cd)

                                                                case Types.BIT:
                        type.setJdbcTypeName("BIT"); //$NON-NLS-1$
                        type.setFullyQualifiedJavaType(new 
FullyQualifiedJavaType(Object.class.getName()));
                        break;

why you map BIt with class Object?

i add the sun notes about mapping sql types with java types

9.3.3 BIT

The JDBC type BIT represents a single bit value that can be zero or one.

SQL-92 defines an SQL BIT type. However, unlike the JDBC BIT type, this SQL-92 
BIT type can be used as a parameterized type to define a fixed-length binary 
string. Fortunately, SQL-92 also permits the use of the simple 
non-parameterized BIT type to represent a single binary digit, and this usage 
corresponds to the JDBC BIT type. Unfortunately, the SQL-92 BIT type is only 
required in "full" SQL-92 and is currently supported by only a subset of the 
major databases. Portable code may therefore prefer to use the JDBC SMALLINT 
type, which is widely supported.

The recommended Java mapping for the JDBC BIT type is as a Java boolean. 

thanks
 

> Abator cannot map  mysql tinyint data type!
> -------------------------------------------
>
>                 Key: IBATIS-434
>                 URL: https://issues.apache.org/jira/browse/IBATIS-434
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: Tools
>         Environment: mysql 5.0.27 fro windows
>            Reporter: Andrea Pantaleoni
>            Priority: Minor
>
> This happens with the current version of Abator
> when Abator  try to map a table in mysql database map the tinyint data type  
> to Object java class
> to reapet:
> Create table if not exists Example (
>                                ID tinyint(1)
>                                               ) 
>                                               ENGINE = InnoDB;
> Abator will create:
> public class Bug {
>     /**
>      * This field was generated by Abator for iBATIS.
>      * This field corresponds to the database column bug.id
>      *
>      * @abatorgenerated Mon Jun 04 14:20:19 CEST 2007
>      */
>     private Object id;
>     /**
>      * This method was generated by Abator for iBATIS.
>      * This method returns the value of the database column bug.id
>      *
>      * @return the value of bug.id
>      *
>      * @abatorgenerated Mon Jun 04 14:20:19 CEST 2007
>      */
>     public Object getId() {
>         return id;
>     }
>     /**
>      * This method was generated by Abator for iBATIS.
>      * This method sets the value of the database column bug.id
>      *
>      * @param id the value for bug.id
>      *
>      * @abatorgenerated Mon Jun 04 14:20:19 CEST 2007
>      */
>     public void setId(Object id) {
>         this.id = id;
>     }
> }
> which is not correct because the type tinyint is mapped to java class Object
> Many thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to