[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3716) Sybase - null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL

Strong Liu (JIRA) noreply at atlassian.com
Mon Jul 26 10:32:35 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37914#action_37914 ] 

Strong Liu commented on HHH-3716:
---------------------------------

ASE doesn't allow 'null' value for 'BIT' datatype;
While performing insert operation using jconn3.jar it permit you to have
'null' value, this 'null' value is converted into bit 0 by jconn3 & hence
ASE doesn't throw any exception;
But incase of jconn4.jar 'null' value is not converted into bit 0, hence
jconn4 directly reports an exception for 'null' value(which is the expected
correct behavior)

> Sybase - null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL
> ----------------------------------------------------------------------------------------------
>
>                 Key: HHH-3716
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3716
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>         Environment: Sybase
>            Reporter: Gail Badner
>            Assignee: Gail Badner
>
> Null values for columns mapped as "boolean" are persisted as 0 (zero) instead of NULL. This happens because Hibernate persists a null Boolean value by calling:
>      PreparedStatement.setNull( index, java.sql.Types.BIT )
> The SQL code, java.sql.Types.BIT, is used because the Hibernate BooleanType defines its code as  java.sql.Type.BIT.
> Sybase JDBC converts the null to 0, apparently because Sybase does not allow nullable bit columns.
> This can be reproduced using an annotations unit test, Java5FeaturesTest.testAutoboxing()..
> Sybase maps bit columns to tinyint, so when the unit test is executed, the column in the underlying table is actually of type tinyint, not bit. Sybase allows nullable tinyint columns, so there should be no problem persisting a null value as null.
> I've verified that changing the call to:
>     PreparedStatement.setNull( index, java.sql.Types.TINYINT )
> persists the null value without being converted to 0.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list