You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Andrea Pantaleoni (JIRA)" <ib...@incubator.apache.org> on 2007/06/04 14:24:35 UTC

[jira] Created: (IBATIS-434) Abator cannot map mysql tinyint data type!

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.


[jira] Commented: (IBATIS-434) Abator cannot map mysql tinyint data type!

Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501199 ] 

Jeff Butler commented on IBATIS-434:
------------------------------------

I don't believe this is a bug - the JDBC driver probably reports this field as Object type because TINYINT is not a standard JDBC type.

In your configuration for this table, you'll have to add a <columnOverride> element to specify the type you desire (java.lang.Short, java.lang.Integer, etc.)

Also - please use the mailing lists for support questions!


> 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.


[jira] Closed: (IBATIS-434) Abator cannot map mysql tinyint data type!

Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/IBATIS-434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Butler closed IBATIS-434.
------------------------------

    Resolution: Fixed

Sorry for taking a while to understand this - but you are correct.  BIT datatype should be mapped to Booelan by default.

It is now fixed in SVN.  In the meantime, you can use a <columnOverride> to force Abator to map a BIT field to java.lang.Boolean.


> 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
>            Assignee: Jeff Butler
>            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.


[jira] Commented: (IBATIS-434) Abator cannot map mysql tinyint data type!

Posted by "Andrea Pantaleoni (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501208 ] 

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

please try to read carefully this page  
http://www.mysql.org/doc/refman/5.0/en/connector-j-reference-type-conversions.html

if you modify the create table in this way:


CREATE TABLE `bug` (
  `id` tinyint(4) default NULL
) ENGINE=INNODB;

abator creates a correct bin;

public class Bug {
    /**
     * This field was generated by Abator for iBATIS.
     * This field corresponds to the database column bug.id
     *
     * @abatorgenerated Mon Jun 04 15:19:06 CEST 2007
     */
    private Byte 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 15:19:06 CEST 2007
     */
    public Byte 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 15:19:06 CEST 2007
     */
    public void setId(Byte id) {
        this.id = id;
    }
}

so the problem is TINYINT(1) and not TINYINT

anyway from connector/j the driver I'm using tiniint is correct mapped.

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.


[jira] Commented: (IBATIS-434) Abator cannot map mysql tinyint data type!

Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501217 ] 

Jeff Butler commented on IBATIS-434:
------------------------------------

What are you expecting Abator to generate?

If you have the property "tinyInt1isBit" set to "true", then I suppose you want a boolean.  Otherwise, a byte.  Is that correct?  But my guess is that the driver still reports "Object" as the data in either instance.  So I still recommend that you use a <columnOverride> to tell Abator what to do in this situation.  This is the reason <columnOverride> exists.

There are other instances in MySql where you need to use <columnOverride> - because MySql has many more type options than JDBC.  There is some information in the Abator documentation about this.


> 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.


[jira] Commented: (IBATIS-434) Abator cannot map mysql tinyint data type!

Posted by "Andrea Pantaleoni (JIRA)" <ib...@incubator.apache.org>.
    [ 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.