mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1499 - findNative with findIds (or findSingleAttributeList with id property) throws ArrayIndexOutOfBoundsException
This commit is contained in:
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user