HHH-11081 - JPA join with treat causes QuerySyntaxException: Invalid path

This commit is contained in:
Andrea Boriero 2016-09-12 23:57:48 +01:00 committed by Gail Badner
parent 4d3ece8c09
commit c9c50d8afd
7 changed files with 5 additions and 61 deletions

View File

@ -22,8 +22,4 @@ public interface FromImplementor<Z,X> extends PathImplementor<X>, From<Z,X> {
FromImplementor<Z,X> correlateTo(CriteriaSubqueryImpl subquery); FromImplementor<Z,X> correlateTo(CriteriaSubqueryImpl subquery);
void prepareCorrelationDelegate(FromImplementor<Z,X> parent); void prepareCorrelationDelegate(FromImplementor<Z,X> parent);
FromImplementor<Z, X> getCorrelationParent(); FromImplementor<Z, X> getCorrelationParent();
default boolean shouldBeRendered(){
return true;
}
} }

View File

@ -336,13 +336,11 @@ public class QueryStructure<T> implements Serializable {
} }
for ( Join join : joins ) { for ( Join join : joins ) {
if ( ((FromImplementor) join).shouldBeRendered() ) { ( (FromImplementor) join ).prepareAlias( renderingContext );
((FromImplementor) join).prepareAlias( renderingContext ); jpaqlQuery.append( renderJoinType( join.getJoinType() ) )
jpaqlQuery.append( renderJoinType( join.getJoinType() ) ) .append( ( (FromImplementor) join ).renderTableExpression( renderingContext ) );
.append( ((FromImplementor) join).renderTableExpression( renderingContext ) ); renderJoins( jpaqlQuery, renderingContext, join.getJoins() );
renderJoins( jpaqlQuery, renderingContext, join.getJoins() ); renderFetches( jpaqlQuery, renderingContext, join.getFetches() );
renderFetches( jpaqlQuery, renderingContext, join.getFetches() );
}
} }
} }

View File

@ -119,16 +119,6 @@ public class CollectionAttributeJoin<O,E>
original.setAlias( alias ); original.setAlias( alias );
} }
@Override
public boolean shouldBeRendered() {
if ( getJoins().size() > 0 ) {
return true;
}
else {
return false;
}
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")"; return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")";

View File

@ -127,16 +127,6 @@ public class ListAttributeJoin<O,E>
original.setAlias( alias ); original.setAlias( alias );
} }
@Override
public boolean shouldBeRendered() {
if ( getJoins().size() > 0 ) {
return true;
}
else {
return false;
}
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")"; return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")";

View File

@ -148,16 +148,6 @@ public class MapAttributeJoin<O,K,V>
original.setAlias( alias ); original.setAlias( alias );
} }
@Override
public boolean shouldBeRendered() {
if ( getJoins().size() > 0 ) {
return true;
}
else {
return false;
}
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")"; return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")";

View File

@ -124,16 +124,6 @@ public class SetAttributeJoin<O,E>
original.setAlias( alias ); original.setAlias( alias );
} }
@Override
public boolean shouldBeRendered() {
if ( getJoins().size() > 0 ) {
return true;
}
else {
return false;
}
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")"; return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")";

View File

@ -159,16 +159,6 @@ public class SingularAttributeJoin<O,X> extends AbstractJoinImpl<O,X> {
return criteriaBuilder().getEntityManagerFactory().getMetamodel().managedType( treatAsType ); return criteriaBuilder().getEntityManagerFactory().getMetamodel().managedType( treatAsType );
} }
@Override
public boolean shouldBeRendered() {
if ( getJoins().size() > 0 ) {
return true;
}
else {
return false;
}
}
@Override @Override
public String render(RenderingContext renderingContext) { public String render(RenderingContext renderingContext) {
return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")"; return "treat(" + original.render( renderingContext ) + " as " + treatAsType.getName() + ")";