Skip to content

Mapping OneToOne relationship broken for immutable entities & PostgreSQL [DATAJDBC-286] #511

@spring-projects-issues

Description

@spring-projects-issues

Maciej Walkowiak opened DATAJDBC-286 and commented

When working with one-to-one relationships, if child entity is immutable it's impossible to fetch entities from the database. 

As far as my investigation has gone, the reason is that column prefix is not passed when data is extracted from result set. 

Example:

SELECT movie.id AS id, movie.title AS title, movie.description AS description, movie.released_date AS released_date, rental.duration AS rental_duration, rental.price AS rental_price, rental.movie AS rental_movie FROM movie LEFT OUTER JOIN movie_rental AS rental ON rental.movie = movie.id 

When mapping Rental entity, Spring Data JDBC currently extracts "duration", "price" instead of "rental_duration" and "rental_price". This works fine with HSQL JDBC driver, but not with PostgreSQL (possibly reason explained at https://www.postgresql.org/message-id/[email protected])

This issue affects only immutable entities. If fields are not final, different mechanism fires up that uses prefixes for getting data from JDBC ResultSet


Referenced from: pull request #99, and commits 2c0a5b7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions