[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6815) ByteTest fails on SQL Server due to driver dropping negative sign due to TINYINT data type
Guenther Demetz (JIRA)
noreply at atlassian.com
Tue Dec 6 05:33:23 EST 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44526#comment-44526 ]
Guenther Demetz commented on HHH-6815:
--------------------------------------
Hi,
I'm not agree with this kind of bugfix:
In my opinion a proper mapping has to provide full value range functionality (!!!),
that means for a byte that all possible values from -256 until 255 must be supported.
I'm aware of the fact that java.lang.byte is signed [-128;+127] whilst its correspondent database type TINYINT is unsigned [0;255], but this is a lesser problem and I believe that Hibernate developers were aware of this fact when they implemented the mapping for the byte.
Anyway, until Hibernate4.0.0CR5 with the official SQLServer driver it was possible to do:
1. define in java byte number = -10;
2. write this byte to database
3. SQLServerDriver stores TINYINT value 246
4. read again value from database
5. returned byte value == -10 (thus full range of byte is supported, YES!)
Now with Hibernate4.0.0.CR6
1. define in java byte number = -10;
2. try to write this byte to database, now following exception raises:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Arithmetic overflow error for data type tinyint, value = -10.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:308)
...
I had a very similar discussion with a bugfix in the JDTs-Driver, see:
http://sourceforge.net/tracker/?func=detail&aid=2945960&group_id=33291&atid=407762
best regards
G.Demetz
> ByteTest fails on SQL Server due to driver dropping negative sign due to TINYINT data type
> ------------------------------------------------------------------------------------------
>
> Key: HHH-6815
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6815
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 4.0.0.CR5
> Environment: MS SQL Server
> Reporter: John Verhaeg
> Assignee: John Verhaeg
> Fix For: 4.0.0.CR6
>
>
> The range for a TINYINT on SQL Server is 0-255, and because we're starting with a byte value, the driver automatically treats it as if it were updating a TINYINT column, even though the actual column being updated is a SMALLINT.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list