Skip to content

When querying using a projection interface and the entity implements said interface than it tries to convert an array to the projection interface [DATAJPA-1644] #1947

Open
@spring-projects-issues

Description

@spring-projects-issues

Mark Czubin opened DATAJPA-1644 and commented

When we create a projection query (i.e. use an interface to denote which fields we want to fetch). And the entity of the repo implements the interface as well.
Then we are unable to execute the query in the repository of the entity. 

The same query does work in other repositories.

 

class X implements Y { 
... lots of fields 
}
interface Y { 
   String getMyField 
}
interface xRepo implements JpaRepository<X, ID> {    
   @Query("select x.myField as myField from X x")    
   List<Y> selectProjection(); 
}

 

This query yields the following error message:

No converter found capable of converting from type [java.lang.String] to type[@org.springframework.data.jpa.repository.Query Y]

 

Workaround:

Place the query in a different repository. 

 

Added as attachment a maven project with the problem and workaround.

 


Attachments:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions