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

Unit test failure on Oracle because constructor cannot be found

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.4
    • Fix Version/s: 5.0.5
    • Component/s: testsuite
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      ConstructorResultNativeQueryTest has @SqlResultSetMapping mappings like the following:

      {{@SqlResultSetMapping(
      name = "person-id-and-name",
      classes = {
      @ConstructorResult(
      targetClass = Person.class,
      columns =

      { @ColumnResult( name = "id" ), @ColumnResult( name = "p_name" ) }

      )
      }
      )}}

      The corresponding constructor is:

      {{public Person(Integer id, String name)

      { this.id = id; this.name = name; }

      }}

      The problem is that, for Oracle, the Integer ID is mapped as a Number(10,0) column, so the value will be returned as a BigDecimal. Because the constructor takes an Integer argument (not a BigDecimal), no appropriate constructor can be found.

      The fix in this case is to specify the type in the @ColumnResult:

      @ColumnResult( name = "id", type=Integer.class )

        Attachments

          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: