Skip to content

Interface projection with native query not working for boolean (mysql) [DATACMNS-1695] #2290

Closed
@spring-projects-issues

Description

@spring-projects-issues

Michal Ondrovic opened DATACMNS-1695 and commented

Simplified test case:

Projection interface:

public interface TestDto {
 Long getId();
 Boolean getTest();
}

Query with projection:

@Query(value = "select 1 id, true test", nativeQuery = true)
List<TestDto> test();

Boolean property "test" is not recognized as Boolean but as Byte. Calling getTest() throws this exception:

java.lang.IllegalArgumentException: Projection type must be an interface!

The projection is working if the boolean field is selected directly from a table, but not, when the field is "calculated".

More workarounds are possible, in my case change "Boolean getTest()" to "Byte getTest()" is the best


Affects: 2.2.6 (Moore SR6)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions