Skip to content

Rewrite string-queries to use constructor expressions when return type is DTO #3076

Closed
@gregturn

Description

@gregturn

Consider the following query:

@Entity
class Person { … }

class PersonProjection { … }


@Query("SELECT p FROM Person p")
PersonProjection findBy(…)

The query selects items from the Person entity while its return type is a DTO projection.

It would be good to rewrite such queries to use DTO projections for matching properties along the lines of:

@Query("SELECT new com.acme.PersonProjection(p.firstName, p.lastName) FROM Person p")
PersonProjection findBy(…)

Metadata

Metadata

Assignees

Labels

in: query-parserEverything related to parsing JPQL or SQLtheme: projectionsRefinements around DTO and interface projectionstype: enhancementA general enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions