#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
@@ -1,6 +1,7 @@
package org.tests.query;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import org.junit.Test;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
@@ -13,6 +14,36 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestQueryFindNative extends BaseTestCase {
@Test
public void findIds() {
ResetBasicData.reset();
String sql = "select c.id from contact c where c.first_name like ? ";
List<Integer> ids = Ebean.createSqlQuery(sql)
.setParameter(1, "J%")
.findSingleAttributeList(Integer.class);
List<Integer> idsScalar =
server()
.findNative(Contact.class, sql)
.setParameter(1, "J%")
.findSingleAttributeList();
List<Integer> nativeIds =
server()
.findNative(Contact.class, sql)
.setParameter(1, "J%")
.findIds();
assertThat(nativeIds).isNotEmpty();
assertThat(nativeIds).containsAll(ids);
assertThat(idsScalar).containsAll(ids);
}
@Test
public void joinFromManyToOne() {