Skip to content

Constructor based instantiation of entities fails due to missing converters. [DATAGRAPH-1182] #1712

New issue

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

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

Already on GitHub? # to your account

Closed
spring-projects-issues opened this issue Jan 16, 2019 · 0 comments
Assignees
Labels
in: core Issues in core support type: bug A general bug

Comments

@spring-projects-issues
Copy link

Michael Simons opened DATAGRAPH-1182 and commented

Given an entity like

class Person {
    Integer something;

    public Person(Integer something) {
        this.something = something;
    }
}

Instantiation of such an entity during load fails with an ConverterNotFoundException:

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Long] to type [java.lang.Integer]
	at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.data.neo4j.conversion.Neo4jOgmEntityInstantiatorAdapter$Neo4jPropertyValueProvider.getParameterValue(Neo4jOgmEntityInstantiatorAdapter.java:84) ~[spring-data-neo4j-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.springframework.data.convert.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:250) ~[spring-data-commons-2.1.4.RELEASE.jar:2.1.4.RELEASE]
	at org.springframework.data.convert.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:223) ~[spring-data-commons-2.1.4.RELEASE.jar:2.1.4.RELEASE]
	at org.springframework.data.convert.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:84) ~[spring-data-commons-2.1.4.RELEASE.jar:2.1.4.RELEASE]
	at org.springframework.data.neo4j.conversion.Neo4jOgmEntityInstantiatorAdapter.createInstance(Neo4jOgmEntityInstantiatorAdapter.java:57) ~[spring-data-neo4j-5.1.4.RELEASE.jar:5.1.4.RELEASE]
	at org.neo4j.ogm.metadata.reflect.EntityFactory.instantiate(EntityFactory.java:126) ~[neo4j-ogm-core-3.1.6.jar:3.1.6]
	at org.neo4j.ogm.metadata.reflect.EntityFactory.newObject(EntityFactory.java:95) ~[neo4j-ogm-core-3.1.6.jar:3.1.6]
	at org.neo4j.ogm.context.GraphEntityMapper.mapNodes(GraphEntityMapper.java:237) ~[neo4j-ogm-core-3.1.6.jar:3.1.6]
	at org.neo4j.ogm.context.GraphEntityMapper.mapEntities(GraphEntityMapper.java:212) ~[neo4j-ogm-core-3.1.6.jar:3.1.6]
	... 51 common frames omitted

This happens in all scenarios where no default Spring converters are defined or more than one.

The ParameterValueProvider for Neo4j's persistent properties then returns the numerical long value from the driver as is (see org.springframework.data.neo4j.conversion.Neo4jOgmEntityInstantiatorAdapter.Neo4jPropertyValueProvider).

This doesn't happen when the entity is instantiated with the default constructor and it's fields are written by OGM, as OGM forcefully coerces longs into ints


Affects: 5.2 M1 (Moore), 5.1.4 (Lovelace SR4)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: core Issues in core support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants