File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/main/java/org/springframework/data/neo4j/core/mapping Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1717
1818import org .apiguardian .api .API ;
1919import org .springframework .data .mapping .PropertyPath ;
20+ import org .springframework .util .StringUtils ;
2021
2122import java .util .HashSet ;
2223import java .util .Map ;
@@ -79,10 +80,17 @@ public boolean contains(String dotPath, Class<?> typeToCheck) {
7980 return false ;
8081 }
8182
82- Optional <String > first = projectingPropertyPaths .keySet ().stream ().sorted ((o1 , o2 ) -> Integer .compare (o2 .length (), o1 .length ())).filter (dotPath ::contains ).findFirst ();
83+ // create a sorted list of the deepest paths first
84+ Optional <String > candidate = projectingPropertyPaths .keySet ().stream ().sorted ((o1 , o2 ) -> {
85+ int depth1 = StringUtils .countOccurrencesOf (o1 , "." );
86+ int depth2 = StringUtils .countOccurrencesOf (o2 , "." );
8387
84- return projectingPropertyPaths .containsKey (dotPath ) ||
85- (first .isPresent () && projectingPropertyPaths .get (first .get ()));
88+ return Integer .compare (depth2 , depth1 );
89+ })
90+ .filter (d -> dotPath .contains (d ) && dotPath .startsWith (d )).findFirst ();
91+
92+ return projectingPropertyPaths .containsKey (dotPath )
93+ || (dotPath .contains ("." ) && candidate .isPresent () && projectingPropertyPaths .get (candidate .get ()));
8694 }
8795
8896 @ Override
You can’t perform that action at this time.
0 commit comments