Skip to content
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

DATAGRAPH-1109 - Add support for persistence constructors for @QueryResults #418

Closed
wants to merge 3 commits into from

Conversation

michael-simons
Copy link
Collaborator

We support persistence constructors for classes annotated as @NodeEntity but not for projections based on DTOS annotated with @QueryResult.

This PR provides persistence constructors for those projections as well, reducing the amount of different programming models a user has to deal with.

The PR is centered around the idea to make OgmEntityInstantiatorAdapter a public api as Neo4jOgmEntityInstantiatorAdapter in the conversion package much as similar concepts in the Mongo store. It also drops the idea of OgmReflectionEntityInstantiator being solely an indirection against OGMs 3.1 ReflectionEntityInstantiator. The guard whether the later is available is still applied (in CustomResultConverter).

OgmReflectionEntityInstantiator becomes QueryResultInstantiator as dedicated means of instantiating DTOs from a custom result. It either uses the ReflectionEntityInstantiator as before or the new public api Neo4jOgmEntityInstantiatorAdapter if applicable.

It is applicable if it get hold of the Neo4jMappingContext.

To pass this around, the Neo4jRepositoryFactoryBean and Neo4jRepositoryFactory have been extended to transport it up to the GraphQueryMethod, again, much as the Mongo store does.

From there on it's accessible in all query related scenarios.

The MappingContext has to be passed on, starting from the Neo4jRepositoryFactoryBean to the Neo4jRepositoryFactory and eventually to the GraphQueryMethod.

The GraphRepositoryQuery than uses it for creating the CustomResultConverter.
The OgmReflectionEntityInstantiator has been renamed and repurposed to a general QueryResultInstantiator which uses the OgmEntityInstantiator adapter if possible, otherwise the existing reflection based instantiator.
@meistermeier
Copy link
Collaborator

Merged with commit aa9ba9e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants