NPE if a query contains more than one parameter with implicitConversion disabled #1163

This commit is contained in:
Konstantin Krivopustov 2018-08-17 10:13:14 +04:00
parent 6d708bf663
commit eca568b595
2 changed files with 15 additions and 1 deletions

View File

@ -152,4 +152,18 @@ class DataManagerTest extends Specification {
noExceptionThrown()
count > 0
}
def "more than one parameter without implicit conversion #1163"() {
when:
LoadContext.Query query = LoadContext.createQuery('select e from test$Foo e where e.ref1 = :ref1 and e.ref2 = :ref2')
.setParameter('ref1', 'val1', false)
.setParameter('ref2', 'val2', false)
.setParameter('ref3', 'val3', false)
then:
query.getNoConversionParams() == ['ref1', 'ref2', 'ref3'].toArray(new String[0])
}
}

View File

@ -367,7 +367,7 @@ public class LoadContext<E extends Entity> implements DataLoadContext, Serializa
// this is a rare case, so let's save some memory by using an array instead of a list
if (noConversionParams == null)
noConversionParams = new String[0];
noConversionParams = new String[noConversionParams.length + 1];
noConversionParams = Arrays.copyOfRange(noConversionParams, 0, noConversionParams.length + 1);
noConversionParams[noConversionParams.length - 1] = name;
}
return this;