FAQ
MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
---------------------------------------------------------------------------------

Key: CAY-1125
URL: https://issues.apache.org/cayenne/browse/CAY-1125
Project: Cayenne
Issue Type: Bug
Components: Cayenne Core Library
Affects Versions: 2.0 [STABLE]
Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
Reporter: Ricardo Ghisi Tobaldini
Assignee: Andrus Adamchik


When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.

This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).

Forcing the type to INTEGER in the map.xml changes anything.

It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).

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

Search Discussions

  • Anonymous at Oct 16, 2008 at 6:50 am
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13168#action_13168 ]

    Andrus Adamchik commented on CAY-1125:
    --------------------------------------

    A few questions:

    1. > Forcing the type to INTEGER in the map.xml changes anything.

    Could you please clarify this - does it fix the problem or not?

    2. What query is causing the error? Could you post a stack trace of the exception?
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik

    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 2:04 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Ricardo Ghisi Tobaldini updated CAY-1125:
    -----------------------------------------

    Attachment: stacktrace.txt

    Stack trace when the exception is raised
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: stacktrace.txt


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 2:04 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13169#action_13169 ]

    Ricardo Ghisi Tobaldini commented on CAY-1125:
    ----------------------------------------------

    Sorry for the lack of details, here it goes.
    Forcing the type to INTEGER in the map.xml changes anything.
    Could you please clarify this - does it fix the problem or not?
    What query is causing the error? Could you post a stack trace of the exception?
    I have discovered now that, when I use a SelectQuery() to retrieve all the rows of a table, I can read the unsigned smallint values (as Integers) AFTER I force the type to java.lang.Integer (on the map.xml).

    But when I use a SQLTemplate with a query of the kind "select * from", even with java.lang.Integer on the map.xml, raises an exception (com.mysql.jdbc.exceptions.jdbc4.MySQLDataException)

    Following this post I will attach the stack trace, the dump of the database used in the tests and the source of the tests.

    Thanks, Andrus, for the feedback :)
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: stacktrace.txt


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 2:06 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Ricardo Ghisi Tobaldini updated CAY-1125:
    -----------------------------------------

    Attachment: testDump.sql

    Dump of the database used in the tests
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 2:06 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Ricardo Ghisi Tobaldini updated CAY-1125:
    -----------------------------------------

    Attachment: source.zip

    Source code of the tests I made to reproduce the problem.

    The tests fails on the second test case.
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 2:53 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174#action_13174 ]

    Andrus Adamchik commented on CAY-1125:
    --------------------------------------

    Can you try remapping the DbAttribute type from SMALLINT to INTEGER. I think this is what causing the problem...
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 3:03 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13175#action_13175 ]

    Ricardo Ghisi Tobaldini commented on CAY-1125:
    ----------------------------------------------

    I tried but that changes nothing too.
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 16, 2008 at 3:08 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13176#action_13176 ]

    Andrus Adamchik commented on CAY-1125:
    --------------------------------------

    Thanks for confirming that. We will take a look.
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 19, 2008 at 12:14 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13178#action_13178 ]

    Andrus Adamchik commented on CAY-1125:
    --------------------------------------

    This seems to be a 2.0-only problem. I can't reproduce it on 3.0. SQLTemplate is much more robust in 3.0, so I suspect there's no easy 2.0 fix. Can you possibly upgrade to 3.0M4 and try it again?
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 24, 2008 at 11:49 am
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182#action_13182 ]

    Ricardo Ghisi Tobaldini commented on CAY-1125:
    ----------------------------------------------

    With the 3.0M4 version it works.
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
  • Anonymous at Oct 24, 2008 at 2:06 pm
    [ https://issues.apache.org/cayenne/browse/CAY-1125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Andrus Adamchik closed CAY-1125.
    --------------------------------

    Resolution: Cannot Reproduce

    Great. So I am closing the Jira.
    MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
    ---------------------------------------------------------------------------------

    Key: CAY-1125
    URL: https://issues.apache.org/cayenne/browse/CAY-1125
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Ubuntu Linux 8.04, Java 1.6.0_07, MySQL 5.0.51a-3ubuntu5.1, MySQL Connector/J 5.1.6
    Reporter: Ricardo Ghisi Tobaldini
    Assignee: Andrus Adamchik
    Attachments: source.zip, stacktrace.txt, testDump.sql


    When trying to retrieve the value of a column that is of type "SMALLINT UNSIGNED" an exception of type com.mysql.jdbc.exceptions.jdbc4.MySQLDataException is raised.
    This only happens if the value on that column is greater than 32767, since it overflows the Java Short type (that is always signed).
    Forcing the type to INTEGER in the map.xml changes anything.
    It seems that Cayenne is using a getShort() when it should use getInteger() (the later is always needed when using the unsigned version of SMALLINT in the database, doesn't it?).
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedOct 15, '08 at 10:21p
activeOct 24, '08 at 2:06p
posts12
users1
websitecayenne.apache.org

1 user in discussion

Anonymous: 12 posts

People

Translate

site design / logo © 2022 Grokbase