File tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed 
hibernate-core/src/main/java/org/hibernate/query/sqm/tree Expand file tree Collapse file tree 4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 66
77import  java .util .HashSet ;
88import  java .util .Set ;
9- import  java .util .stream .Collectors ;
109
1110import  org .hibernate .query .sqm .NodeBuilder ;
1211import  org .hibernate .query .sqm .SqmQuerySource ;
@@ -103,6 +102,6 @@ public Set<ParameterExpression<?>> getParameters() {
103102
104103	@ Override 
105104	public  String  generateAlias () {
106- 		return  "t_ "  + (++aliasCounter );
105+ 		return  "var_ "  + (++aliasCounter );
107106	}
108107}
Original file line number Diff line number Diff line change @@ -93,11 +93,12 @@ public void clearFetched() {
9393	}
9494
9595	private  void  validateFetchAlias (String  alias ) {
96- //		if ( fetchJoin && alias != null && nodeBuilder().isJpaQueryComplianceEnabled() ) { 
97- //			throw new IllegalStateException( 
98- //					"The JPA specification does not permit specifying an alias for fetch joins." 
99- //			); 
100- //		} 
96+ 		if  ( fetchJoin  && alias  != null  && !alias .startsWith ( "var_"  )
97+ 				&& nodeBuilder ().isJpaQueryComplianceEnabled () ) {
98+ 			throw  new  IllegalStateException (
99+ 					"The JPA specification does not permit specifying an alias for fetch joins." 
100+ 			);
101+ 		}
101102	}
102103
103104	@ Override 
Original file line number Diff line number Diff line change @@ -976,6 +976,16 @@ public JpaExpression<?> id() {
976976	private  int  aliasCounter  = 0 ;
977977
978978	private  String  generateAlias () {
979- 		return  alias  + "_"  + (++aliasCounter );
979+ 		final  String  prefix ;
980+ 		if  ( alias  == null  ) {
981+ 			prefix  = "var_" ;
982+ 		}
983+ 		else  if  ( alias .startsWith ( "var_"  ) ) {
984+ 			prefix  = alias ;
985+ 		}
986+ 		else  {
987+ 			prefix  = "var_"  + alias ;
988+ 		}
989+ 		return  prefix  + "_"  + (++aliasCounter );
980990	}
981991}
Original file line number Diff line number Diff line change @@ -626,6 +626,6 @@ else if ( !newSelections.contains( selection ) ) {
626626
627627	@ Override 
628628	public  String  generateAlias () {
629- 		return  "t_ "  + (++aliasCounter );
629+ 		return  "var_ "  + (++aliasCounter );
630630	}
631631}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments