0

I want to map my query result to RequestProjection interface values. The following code works and return request id and submission date.

I need to return worker name too. I have tried r.worker_name AS workerName and r.worker_name AS worker_name and r.worker_name AS worker.name but none of them works.

How can I select and map worker name?

Query:

SELECT r.id AS id, r.submission_date AS submissionDate
From Request r
WHERE r.id = 1

Projection:

public interface RequestProjection {

    Long getId();

    Long getSubmissionDate();

    Worker getWorker();

    interface Worker {

        String getName();
    }
}
Jumana Alhaddad
  • 285
  • 2
  • 6
  • 17

1 Answers1

-2

You can do this without native query using the constructor expression, read more here Spring JPA native query with Projection gives "ConverterNotFoundException"

DarkFeud
  • 181
  • 2
  • 16