null values for columns mapped as "boolean" cause exception when saving entity with Sybase jdbc4

Description

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)

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.

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.

Attachments

1

Activity

Show:

Brett MeyerMarch 7, 2014 at 10:07 PM

Bulk closing tickets resolved in released versions

Strong LiuNovember 2, 2011 at 5:19 PM

I believe this is fixed by HHH-6795, at least jConnect4

Raphaël LemaireSeptember 16, 2010 at 10:38 AM

Hi,

Here's a Maven project that should make the problem appear.

I've also been able to reproduce the problem using low level JDBC, changing the SQL type.

Hope it helps.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created July 26, 2010 at 4:55 PM
Updated March 7, 2014 at 10:07 PM
Resolved November 2, 2011 at 5:19 PM