Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-4731

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • TBD EAP 5
    • EAP_EWP 5.1.0_CR1, EAP_EWP 5.1.0_CR2
    • Hibernate
    • None
    • Sybase ASE 15 with jdbc4

    • Release Notes
    • Workaround Exists
    • Hide

      There is a class in the unit tests, org.hibernate.test.where.NumericTrueFalseType, that could be used as a workaround for mapping boolean columns.

      To use the workaround, instead of mapping:
      type="boolean"
      use:
      type="org.hibernate.test.where.NumericTrueFalseType"

      Show
      There is a class in the unit tests, org.hibernate.test.where.NumericTrueFalseType, that could be used as a workaround for mapping boolean columns. To use the workaround, instead of mapping: type="boolean" use: type="org.hibernate.test.where.NumericTrueFalseType"
    • Hide
      When an insert operation was performed using <filename>jconn3.jar</filename>, null bit values were converted to <literal>0</literal>, so no exception was thrown. Sybase does not allow a null value for the bit datatype, so null bit values should result in exceptions.
      There is a class in the unit tests, org.hibernate.test.where.NumericTrueFalseType, that could be used as a workaround for mapping boolean columns.
      To use the workaround, instead of mapping:
      type="boolean"
      use:
      type="org.hibernate.test.where.NumericTrueFalseType"
      Show
      When an insert operation was performed using <filename>jconn3.jar</filename>, null bit values were converted to <literal>0</literal>, so no exception was thrown. Sybase does not allow a null value for the bit datatype, so null bit values should result in exceptions. There is a class in the unit tests, org.hibernate.test.where.NumericTrueFalseType, that could be used as a workaround for mapping boolean columns. To use the workaround, instead of mapping: type="boolean" use: type="org.hibernate.test.where.NumericTrueFalseType"
    • Documented as Known Issue

    Description

      http://opensource.atlassian.com/projects/hibernate/browse/HHH-5413
      ------------------
      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

        Issue Links

          Activity

            People

              shaozliu Strong Liu(刘少壮) (Inactive)
              shaozliu Strong Liu(刘少壮) (Inactive)
              Laura Bailey Laura Bailey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: