Skip to content

Impossible to get Related entity with MappingR2dbcConverter #737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
myosotys opened this issue Mar 7, 2022 · 2 comments
Closed

Impossible to get Related entity with MappingR2dbcConverter #737

myosotys opened this issue Mar 7, 2022 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@myosotys
Copy link

myosotys commented Mar 7, 2022

Hello,

I have a small problem, i use MappingR2dbcConverter to map my entity, but I recently update the version (1.2.15 but i think the problem is always present) and i have a problem with related entity. I think the problem (if the problem is not me) is in this code

private Object readFrom(Row row, @Nullable RowMetadata metadata, RelationalPersistentProperty property,
		String prefix) {

	String identifier = prefix + property.getColumnName().getReference();

	try {

		Object value = null;
		if (metadata == null || RowMetadataUtils.containsColumn(metadata, identifier)) {
			value = row.get(identifier);
		}

		if (value == null) {
			return null;
		}

		if (getConversions().hasCustomReadTarget(value.getClass(), property.getType())) {
			return readValue(value, property.getTypeInformation());
		}

		if (property.isEntity()) {
			return readEntityFrom(row, metadata, property);
		}

		return readValue(value, property.getTypeInformation());

	} catch (Exception o_O) {
		throw new MappingException(String.format("Could not read property %s from column %s!", property, identifier),
				o_O);
	}
}

In case of related entity, the code never go to "readEntityFrom" because "RowMetadataUtils.containsColumn(metadata, identifier)" cannot be true
Work before cause "property.isEntity()" was checked before return null.

Example:

User{
	String id;
	Client client;
}
Client{
	String id;
	String name;
}

The row returned container column: id, client_id and client_name but the function readFrom search an identifier "client" that doest not exist.

Am I missing something ?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 7, 2022
@mp911de
Copy link
Member

mp911de commented Mar 7, 2022

This is a known limitation. Nested entities are not supported, see #288

@mp911de mp911de closed this as completed Mar 7, 2022
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 7, 2022
@myosotys
Copy link
Author

myosotys commented Mar 7, 2022

it was not a limitation before (at least for this class). My example work fine in 1.2.14, not in 1.2.15 and higher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants