mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1436 - PersistenceException: Query threw SQLException:No ScalarType registered for class java.util.Arrays$ArrayList Query was:select id, name from o_customer where id = any(?)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package io.ebean;
|
||||
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.meta.BasicMetricVisitor;
|
||||
import io.ebean.meta.MetaQueryMetric;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
@@ -8,6 +10,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -98,6 +101,48 @@ public class DtoQueryTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
|
||||
@ForPlatform(Platform.POSTGRES)
|
||||
@Test
|
||||
public void dto_bindList_usingPostrgesAnyWithPositionedParameter() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Integer> ids = Arrays.asList(1, 2);
|
||||
|
||||
List<DCust> list = server().findDto(DCust.class, "select id, name from o_customer where id = any(?)")
|
||||
.setParameter(1, ids)
|
||||
.findList();
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
|
||||
list = server().findDto(DCust.class, "select id, name from o_customer where id in (:idList)")
|
||||
.setParameter("idList", ids)
|
||||
.findList();
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
}
|
||||
|
||||
@ForPlatform(Platform.POSTGRES)
|
||||
@Test
|
||||
public void sql_bindListParam_usingPostrgesAnyWithPositionedParameter() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Integer> ids = Arrays.asList(1, 2);
|
||||
|
||||
List<SqlRow> list = server().createSqlQuery("select id, name from o_customer where id = any(?)")
|
||||
.setParameter(1, ids)
|
||||
.findList();
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
|
||||
list = server().createSqlQuery("select id, name from o_customer where id in (:idList)")
|
||||
.setParameter("idList", ids)
|
||||
.findList();
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dto_queryPlanHits() {
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.SqlQuery;
|
||||
import io.ebean.SqlRow;
|
||||
import org.tests.model.basic.TUuidEntity;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.TUuidEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -41,5 +43,19 @@ public class TestSqlRowUUID extends BaseTestCase {
|
||||
|
||||
assertThat(value).isEqualTo(e.getId());
|
||||
|
||||
if (isPostgres()) {
|
||||
usingPostrgesAnyWithPositionedParameter_needsExplicitCast(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void usingPostrgesAnyWithPositionedParameter_needsExplicitCast(TUuidEntity e) {
|
||||
|
||||
List<UUID> ids = Arrays.asList(e.getId(), UUID.randomUUID());
|
||||
|
||||
List<SqlRow> result = Ebean.createSqlQuery("select id from tuuid_entity where id = any(?::uuid[])")
|
||||
.setParameter(1, ids)
|
||||
.findList();
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user