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

Mapping Exception for entities with same Simple ClassName but different Labels #726

Closed
viggys opened this issue Dec 19, 2019 · 4 comments
Closed
Assignees

Comments

@viggys
Copy link

viggys commented Dec 19, 2019

I have two entity classes with same SimpleName but in different packages and with different NodeEntity Labels. All the repository methods seem to work fine with both the classes, except for any repository method using @ Query annotation.

Facing OGM MappingException: More than one class has simple name.
This is happening as the class SimpleName is being used (in below code) to find the ClassInfo from session metadata, where actually the ClassInfo is mapped using either the NodeEntity Label or the Class FQN.

org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.lambda$executeAndMap$1(ExecuteQueriesDelegate.java:119)
session.metaData().classInfo(type.getSimpleName())

Expected Behavior

To find the mapping ClassInfo, execute and return the Query result.

Current Behavior

Facing below OGM Exception,
org.neo4j.ogm.exception.core.MappingException: More than one class has simple name

Possible Solution

Using Class FullQualifiedName instead of SimpleName ExecuteQueriesDelegate.executeAndMap to find the ClassInfo seems to work. Expecting suggestions on the fix.

Steps to Reproduce (for bugs)

  1. Create two POJOs with same Name, but in different packages with different NodeEntity labels
  2. Create a repository method using native @ Query

Context

The goal is to use multiple node entity classes with same name but in different packages and work with the spring data repositories.

Your Environment

  • OGM Version used: 3.1.5
  • Java Version used: 1.8
  • Neo4J Version used: 3.5.0
@meistermeier
Copy link
Collaborator

Related to #552 / #712

@meistermeier
Copy link
Collaborator

Thanks for reporting this. You are totally right with your finding and that this should not happen. A fix is on its way.

meistermeier added a commit that referenced this issue Dec 20, 2019
With this change it is possible to have multiple classes
with the same simple class name in the application's domain model.

In cases when custom queries were created this failed because
of a unnecessary guard.

This fixes GH-726.
@viggys
Copy link
Author

viggys commented Dec 20, 2019

Cool. Thank you @meistermeier for your immediate fix. This should solve the issue.

@michael-simons
Copy link
Collaborator

Thanks, @viggys for your report :) we will close the ticket as soon as the fix is on the relevant branches.

meistermeier added a commit that referenced this issue Dec 20, 2019
With this change it is possible to have multiple classes
with the same simple class name in the application's domain model.

In cases when custom queries were created this failed because
of a unnecessary guard.

This fixes GH-726.
meistermeier added a commit that referenced this issue Dec 23, 2019
And don't use old parameter placeholders.
meistermeier added a commit that referenced this issue Dec 23, 2019
And don't use old parameter placeholders.

(cherry picked from commit 81f1dd8)
meistermeier added a commit that referenced this issue Dec 23, 2019
With this change it is possible to have multiple classes
with the same simple class name in the application's domain model.

In cases when custom queries were created this failed because
of a unnecessary guard.
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

No branches or pull requests

3 participants