Changeset 5046


Ignore:
Timestamp:
Aug 12, 2009, 11:12:48 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1357: Incorrect HQL is generated when sorting on an aliased property that is followed by an association path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r4988 r5046  
    10391039          {
    10401040            String toJoin = sortProperty.substring(0, dotIndex);
     1041            if (alias != null) toJoin = "$" + alias + "." + toJoin;
    10411042            leftJoins.add(toJoin);
    10421043            sortedProperties.add(toJoin);
     
    11171118      {
    11181119        boolean fetch = selectOrderBy && sortedProperties.contains(property);
     1120        String alias = null;
    11191121        if (property.startsWith("@") || property.startsWith("£") || property.startsWith("&"))
    11201122        {
    11211123          property = property.substring(1);
    11221124        }
     1125        if (property.startsWith("$"))
     1126        {
     1127          int dotIndex = property.indexOf('.');
     1128          alias = property.substring(1, dotIndex);
     1129          property = property.substring(dotIndex+1);
     1130        }
    11231131        i++;
    1124         query.join(Hql.leftJoin(null, property, "alj"+i, null, fetch));
     1132        query.join(Hql.leftJoin(alias, property, "alj"+i, null, fetch));
    11251133      }
    11261134    }
Note: See TracChangeset for help on using the changeset viewer.