Use UnderscoreTemplates

This commit is contained in:
Timo Westkämper 2015-03-26 19:11:19 +02:00
parent e100e9800a
commit 11825e2ad2
2 changed files with 12 additions and 2 deletions

View File

@ -544,6 +544,16 @@ public final class ExpressionUtils {
return variable + "_" + suffix;
}
/**
* Create a new root variable based on the given path
*
* @param path
* @return
*/
public static String createRootVariable(Path<?> path) {
return path.accept(ToStringVisitor.DEFAULT, TEMPLATES);
}
/**
* Converts the given object to an Expression
*

View File

@ -137,7 +137,7 @@ public class JPAQueryMixin<T> extends QueryMixin<T> {
}
} else if (metadata.getParent().getMetadata().isRoot()) {
Class<T> type = getElementTypeOrType(path);
Path<T> newPath = new PathImpl<T>(type, path.toString().replace('.', '_'));
Path<T> newPath = new PathImpl<T>(type, ExpressionUtils.createRootVariable(path));
leftJoin(path, newPath);
return newPath;
} else {
@ -145,7 +145,7 @@ public class JPAQueryMixin<T> extends QueryMixin<T> {
Path<?> parent = shorten(metadata.getParent(), paths);
Path<T> oldPath = new PathImpl<T>(path.getType(),
new PathMetadata(parent, metadata.getElement(), metadata.getPathType()));
Path<T> newPath = new PathImpl<T>(type, oldPath.toString().replace('.', '_'));
Path<T> newPath = new PathImpl<T>(type, ExpressionUtils.createRootVariable(oldPath));
aliases.put(path, newPath);
leftJoin(oldPath, newPath);
return newPath;