Skip to content

Deterministic mapping of records with mixed results #2246

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
meistermeier opened this issue May 6, 2021 · 1 comment
Closed

Deterministic mapping of records with mixed results #2246

meistermeier opened this issue May 6, 2021 · 1 comment
Assignees
Labels
type: enhancement A general enhancement

Comments

@meistermeier
Copy link
Collaborator

Since we do not officially support this, I would call this an enhancement instead of a bug fix ;)

Given that we want to map something like

MATCH (a:DatabaseObject{dbId:$dbId})-[r:output]->(m:PhysicalEntity) RETURN m, r.stoichiometry as n

the mapping mechanism will create a Map that will only contain the identifier and the node description of the template / repository. If this node description is an (abstract) parent class, we will then lose the information about the concrete type coming from the node's label.

@meistermeier meistermeier added the type: enhancement A general enhancement label May 6, 2021
@meistermeier meistermeier added this to the 6.0.9 (2020.0.9) milestone May 6, 2021
@meistermeier meistermeier self-assigned this May 6, 2021
meistermeier added a commit that referenced this issue May 6, 2021
meistermeier added a commit that referenced this issue May 6, 2021
If a record contains more than just a node, for example
a node and an additional field, the labels were ignored.
The default behaviour was to take the nodes provided by the
node description to instantiate the entity class.
This can lead to problems with abstract base classes, because
the detailed information which concrete implementation to choose
from was more or less random.

Closes #2246
meistermeier added a commit that referenced this issue May 6, 2021
If a record contains more than just a node, for example
a node and an additional field, the labels were ignored.
The default behaviour was to take the nodes provided by the
node description to instantiate the entity class.
This can lead to problems with abstract base classes, because
the detailed information which concrete implementation to choose
from was more or less random.

Closes #2246
@gsviteri
Copy link

gsviteri commented May 6, 2021

I am testing using 6.0.9-GH-2246-SNAPSHOT and so far all test cases are passing. That's a great enhancement for the Library! Thank @meistermeier. Thanks a lot

It will be really useful to get this code snippet somewhere in the documentation

BiFunction<TypeSystem, MapAccessor, DatabaseObject> mappingFunction = neo4jMappingContext.getRequiredMappingFunctionFor(DatabaseObject.class);
        Collection<QueryResultWrapper> wrapper = neo4jClient.query("MATCH (a:DatabaseObject{dbId:$dbId})-[r:input]->(m:PhysicalEntity) RETURN m, 3 as n")
                .bindAll(map).fetchAs(QueryResultWrapper.class)
                .mappedBy((typeSystem, record) -> {
                    DatabaseObject n = mappingFunction.apply(typeSystem, record.get("m"));
                    int number = record.get("n").asInt();
                    return new QueryResultWrapper(n, number);
                }).all();

meistermeier added a commit that referenced this issue May 6, 2021
If a record contains more than just a node, for example
a node and an additional field, the labels were ignored.
The default behaviour was to take the nodes provided by the
node description to instantiate the entity class.
This can lead to problems with abstract base classes, because
the detailed information which concrete implementation to choose
from was more or less random.

Closes #2246
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants