We're updating the issue view to help you get more done. 

Unit test failure on Oracle because constructor cannot be found

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 )

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.4

Priority

Major