#1499 - findNative with findIds (or findSingleAttributeList with id property) throws ArrayIndexOutOfBoundsException

This commit is contained in:
rob bygrave
2018-10-04 22:51:51 +13:00
parent 9a6d339449
commit fc26765a7e
3 changed files with 36 additions and 1 deletions
@@ -148,7 +148,10 @@ class SqlTreeNodeBean implements SqlTreeNode {
public ScalarType<?> getSingleAttributeScalarType() {
if (properties == null || properties.length == 0) {
// if we have no property ask first children (in a distinct select with join)
// if we have also no children, NPE happens anyway.
if (children.length == 0) {
// expected to be a findIds query
return desc.getIdBinder().getBeanProperty().getScalarType();
}
return children[0].getSingleAttributeScalarType();
}
if (properties[0] instanceof STreePropertyAssocOne) {
@@ -769,6 +769,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
copy.mapKey = mapKey;
copy.id = id;
copy.label = label;
copy.nativeSql = nativeSql;
copy.useBeanCache = useBeanCache;
copy.useQueryCache = useQueryCache;
copy.readOnly = readOnly;