@@ -118,12 +118,12 @@ public Select count() {
118118 }
119119
120120 @ Override
121- public Select instantiate (String resultType , Collection <String > paths ) {
121+ public Select instantiate (String resultType , Collection <PathAndOrigin > paths ) {
122122 return new Select (postProcess (new ConstructorExpression (resultType , new Multiselect (from , paths ))), from );
123123 }
124124
125125 @ Override
126- public Select select (Collection <String > paths ) {
126+ public Select select (Collection <PathAndOrigin > paths ) {
127127 return new Select (postProcess (new Multiselect (from , paths )), from );
128128 }
129129
@@ -411,36 +411,35 @@ public interface SelectStep {
411411 * @param paths
412412 * @return
413413 */
414- default Select instantiate (Class <?> resultType , Collection <String > paths ) {
414+ default Select instantiate (Class <?> resultType , Collection <PathAndOrigin > paths ) {
415415 return instantiate (resultType .getName (), paths );
416416 }
417417
418418 /**
419- * Provide a constructor expression to instantiate {@code resultType}. Operates on the underlying {@link Entity
420- * FROM}.
419+ * Provide a constructor expression to instantiate {@code resultType}.
421420 *
422421 * @param resultType
423422 * @param paths
424423 * @return
425424 */
426- Select instantiate (String resultType , Collection <String > paths );
425+ Select instantiate (String resultType , Collection <PathAndOrigin > paths );
427426
428427 /**
429- * Specify a multi-select. Operates on the underlying {@link Entity FROM}.
428+ * Specify a multi-select.
430429 *
431430 * @param paths
432431 * @return
433432 */
434- Select select (Collection <String > paths );
433+ Select select (Collection <PathAndOrigin > paths );
435434
436435 /**
437- * Select a single attribute. Operates on the underlying {@link Entity FROM}.
436+ * Select a single attribute.
438437 *
439438 * @param name
440439 * @return
441440 */
442- default Select select (String name ) {
443- return select (List .of (name ));
441+ default Select select (PathAndOrigin path ) {
442+ return select (List .of (path ));
444443 }
445444
446445 }
@@ -529,24 +528,21 @@ public String toString() {
529528 * @param source
530529 * @param paths
531530 */
532- record Multiselect (Origin source , Collection <String > paths ) implements Selection {
531+ record Multiselect (Origin source , Collection <PathAndOrigin > paths ) implements Selection {
533532
534533 @ Override
535534 public String render (RenderContext context ) {
536535
537536 StringBuilder builder = new StringBuilder ();
538537
539- for (String path : paths ) {
538+ for (PathAndOrigin path : paths ) {
540539
541540 if (!builder .isEmpty ()) {
542541 builder .append (", " );
543542 }
544543
545- builder .append (context .prefixWithAlias (source , path ));
546-
547- if (!path .contains ("." )) {
548- builder .append (" " ).append (path );
549- }
544+ builder .append (PathExpression .render (path , context ));
545+ builder .append (" " ).append (path .path ().getSegment ());
550546 }
551547
552548 return builder .toString ();
@@ -1023,11 +1019,16 @@ record PathExpression(PathAndOrigin pas) implements Expression {
10231019
10241020 @ Override
10251021 public String render (RenderContext context ) {
1022+ return render (pas , context );
1023+
1024+ }
1025+
1026+ public static String render (PathAndOrigin pas , RenderContext context ) {
10261027
10271028 if (pas .path ().hasNext () || !pas .onTheJoin ()) {
1028- return context .prefixWithAlias (pas () .origin (), pas .path ().toDotPath ());
1029+ return context .prefixWithAlias (pas .origin (), pas .path ().toDotPath ());
10291030 } else {
1030- return context .getAlias (pas () .origin ());
1031+ return context .getAlias (pas .origin ());
10311032 }
10321033 }
10331034
0 commit comments