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

ogm mapping issue #1156

Closed
isakovarseniy opened this issue Sep 5, 2024 · 2 comments
Closed

ogm mapping issue #1156

isakovarseniy opened this issue Sep 5, 2024 · 2 comments
Assignees

Comments

@isakovarseniy
Copy link

Expected Behavior

Current Behavior

Context

Your Environment

  • Java version: 17.0.9
  • Neo4j version (The version of the database): 5.20.0
  • OGM Version (The version of this software): 4.0.10
  • OGM Transport used (One of Bolt, HTTP or embedded):
  • Neo4j Java Driver version (in case of Bolt transport): bolt

I have following structure ( See archive ). During search operation

          1. Insert class Window. 
          2. Collection<?> result = session().loadAll( Canvas.class, filters, sortOrder, pager);

error occurred : Multiple classes found in type hierarchy that map to: [Canvas, UObject, Window]
should return class Window.
Issue happens in class org.neo4j.ogm.metadata.Metadata method "resolve"

Archive.zip

@isakovarseniy
Copy link
Author

isakovarseniy commented Sep 5, 2024

I think issue is in MetaData.class

private ClassInfo findSingleImplementor(ClassInfo interfaceInfo) {
    if (interfaceInfo != null && interfaceInfo.directImplementingClasses() != null
        && interfaceInfo.directImplementingClasses().size() == 1) {
        return interfaceInfo.directImplementingClasses().get(0);
    }
    return null;
}

if interface do not have implementation it will return you interface class itself but should return null. Probably should be like this:

private ClassInfo findSingleImplementor(ClassInfo interfaceInfo) {
	if (interfaceInfo != null && interfaceInfo.directImplementingClasses() != null
			&& interfaceInfo.directImplementingClasses().size() == 1) {

		if (interfaceInfo.isInterface()) {
			return null;
		} else {
			return interfaceInfo.directImplementingClasses().get(0);
		}
	}
	return null;
}

or interfaceInfo.directImplementingClasses() should be empty

@michael-simons michael-simons self-assigned this Nov 8, 2024
@michael-simons
Copy link
Collaborator

Thanks for the report. Working on a fix.

michael-simons added a commit that referenced this issue Nov 8, 2024
If several types are resolved and only one of them is a concrete class and the rest interfaces implemented in that class, we can savely assume that it is exactly that what the combination of labels asked for.

Fixes #1156.
michael-simons added a commit that referenced this issue Nov 8, 2024
If several types are resolved and only one of them is a concrete class and the rest interfaces implemented in that class, we can savely assume that it is exactly that what the combination of labels asked for.

Fixes #1156.
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

2 participants