solomax commented on code in PR #334:
URL: https://github.com/apache/openjpa/pull/334#discussion_r4754550641


##########
openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java:
##########
@@ -2214,6 +2228,47 @@ private Value getPathOrConstant(JPQLNode node) {
         }
     }
 
+    /**
+     * Whether the given path starts with an identification variable whose
+     * type has a field named like the second path element (or whose type is
+     * unknown).
+     */
+    private boolean isTraversablePath(JPQLNode node) {
+        String name = firstChild(node).text;
+        if (name == null || node.getChildCount() < 2) {
+            return true;
+        }
+        ClassMetaData meta = getMetaDataForAlias(name);
+        if (meta == null) {
+            Context c = ctx().findContext(name.toLowerCase(Locale.ROOT));
+            if (c == null) {
+                return false;
+            }
+            Value var = c.getVariable(name);
+            meta = var.getMetaData() != null ? var.getMetaData() : 
c.getSchema(name);
+            if (meta == null) {
+                return true;
+            }
+        }
+        return meta.getField(node.children[1].text) != null;
+    }
+
+    /**
+     * Resolve a dotted name such as <code>pkg.Outer.Inner</code> to a nested
+     * class by replacing dots with <code>$</code> from the right.
+     */
+    private Class<?> nestedClassForName(String className) {
+        StringBuilder buf = new StringBuilder(className);
+        for (int dot = className.lastIndexOf('.'); dot > 0; dot = 
className.lastIndexOf('.', dot - 1)) {

Review Comment:
   Why is it `for` loop and not plain `lastIndexOf` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to