0

I have this DTOs (data transfer object):

public record ProjectsDto(long id, String projectName, String contact, String fundingCode, LocalDate runtimeFrom,
                          LocalDate runtimeTo, String costUnit, String chapter, String unit, UsersDto users) {
}

and

public record UsersDto(long id, String userName, String firstName, String lastname) {
}

I have this repository:

@Query("select p.id, p.projectname, p.contact, p.funding_code fundingCode, p.runtime_from runtimeFrom, p.runtime_to runtimeTo, " +
            "p.cost_unit costUnit, p.chapter, p.unit, u.id users_id, u.username userName, u.firstname firstName, u.lastname lastName " +
            "from projects p " +
            "inner join users u on u.id = p.users_id " +
            "where p.id = :id")
    Optional<ProjectsDto> findByIdAndProjectTo(long id);

The ProjectDto gets populated with all the simple properties like runtimeTo for example. But the embedded users being a UserDto won´t get populated.

Do i have an error in my repository?

Thomas Lang
  • 1,285
  • 17
  • 35

1 Answers1

1

This is simply not supported at the moment.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • Are there any plans on doing so? In the meantime i´ve solved it with a database view. By the way - keep up the good work. I´m using Spring Data JDBC in the first place - if i have the choice! – Thomas Lang Mar 16 '23 at 08:09