Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11818

ClassCastException when binding a MaterializedNClobType value as NClob

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.10, 5.1.7
    • Fix Version/s: 5.2.11, 5.1.8
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      org.hibernate.type.MaterializedNClobType has:

      • org.hibernate.type.descriptor.java.StringTypeDescriptor#INSTANCE as its JavaTypeDescriptor
      • org.hibernate.type.descriptor.sql.NClobTypeDescriptor#DEFAULT as its SqlTypeDescriptor

      When org.hibernate.type.descriptor.sql.NClobTypeDescriptor binds a String as an NClob, it calls StringTypeDescriptor#unwrap to "unwrap" the NClob.

      StringTypeDescriptor#unwrap checks if Clob is assignable from the expected type (NClob). Since NClob extends Clob, a Clob is created and returned. This ultimately causes a ClassCastException when binding the returned value as an NClob.

      The fix simply moves the check for an NClob before the check for a Clob, so that an NClob will be returned instead.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                gbadner Gail Badner
                Reporter:
                gbadner Gail Badner
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: