Merged from release_5_6 [from revision 23694]

PL-6081 NullPointerException in query transformer
#PL-6081
This commit is contained in:
Eugeny Degtyarjov 2015-10-14 07:48:18 +00:00
parent 2305a8e15f
commit 157f4056bf
3 changed files with 10 additions and 2 deletions

View File

@ -376,4 +376,12 @@ public class QueryTransformerRegexTest extends TestCase {
"SELECT distinct h.level from sec$Constraint u, sec$GroupHierarchy h join h.parent.constraints c where h.userGroup = :par",
res);
}
public void testNpeInReplaceOrderBy() {
QueryTransformerRegex transformer = new QueryTransformerRegex(
"select drB from taxi$DriverBan drB where drB.driver.id = :ds_driverDs order by drB.from");
String[] properties = new String[]{"driver.name", "driver.callsignName"};
transformer.replaceOrderBy(true, properties);
}
}

View File

@ -23,7 +23,7 @@ public class QueryParserRegex implements QueryParser {
public static final int QS_ALIAS = 2;
public static final String ENTITY_PATTERN_REGEX = "(\\b[_A-Za-z]+\\$[A-Z][_A-Za-z0-9]*)(\\s+as\\b)?\\s+([a-z]+[a-z0-9]*)*\\b";
public static final Pattern ENTITY_PATTERN = Pattern.compile(ENTITY_PATTERN_REGEX);
public static final Pattern ENTITY_PATTERN = Pattern.compile(ENTITY_PATTERN_REGEX, Pattern.CASE_INSENSITIVE);
public static final int EP_ALIAS = 3;
public static final Pattern FROM_ENTITY_PATTERN = Pattern.compile("\\b(from|update)\\s+" + ENTITY_PATTERN_REGEX, Pattern.CASE_INSENSITIVE);

View File

@ -347,7 +347,7 @@ public class QueryTransformerRegex extends QueryParserRegex implements QueryTran
String alias = null;
while (entityMatcher.find()) {
String matchedAlias = entityMatcher.group(EP_ALIAS);
if (matchedAlias.equalsIgnoreCase(firstAlias)) {
if (matchedAlias != null && matchedAlias.equalsIgnoreCase(firstAlias)) {
alias = matchedAlias;
break;
}