mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2857 - @DbArray - slight performance optimisation for empty array
This commit is contained in:
1 parent
8e02dedf9f
commit
227968ef8e
5 files changed
+8
-23
No files matched your search
@@ -10,6 +10,8 @@ import java.sql.Types;
|
|||||||
|
|
||||||
abstract class ScalarTypeArrayBase<T> extends ScalarTypeJsonCollection<T> {
|
abstract class ScalarTypeArrayBase<T> extends ScalarTypeJsonCollection<T> {
|
||||||
|
|
||||||
|
static final Object[] EMPTY_ARRAY = new Object[]{};
|
||||||
|
|
||||||
ScalarTypeArrayBase(Class<T> type, int dbType, DocPropertyType docPropertyType, boolean nullable) {
|
ScalarTypeArrayBase(Class<T> type, int dbType, DocPropertyType docPropertyType, boolean nullable) {
|
||||||
super(type, dbType, docPropertyType, nullable);
|
super(type, dbType, docPropertyType, nullable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,9 @@ import java.lang.reflect.Type;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import static java.util.Collections.EMPTY_LIST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type mapped for DB ARRAY type (Postgres only effectively).
|
* Type mapped for DB ARRAY type (Postgres only effectively).
|
||||||
*/
|
*/
|
||||||
@@ -136,7 +130,7 @@ class ScalarTypeArrayList extends ScalarTypeArrayBase<List> implements ScalarTyp
|
|||||||
if (nullable) {
|
if (nullable) {
|
||||||
binder.setNull(Types.ARRAY);
|
binder.setNull(Types.ARRAY);
|
||||||
} else {
|
} else {
|
||||||
binder.setArray(arrayType, toArray(EMPTY_LIST));
|
binder.setArray(arrayType, EMPTY_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import static java.util.Collections.EMPTY_LIST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* H2 database support for DB ARRAY.
|
* H2 database support for DB ARRAY.
|
||||||
*/
|
*/
|
||||||
@@ -90,7 +88,7 @@ final class ScalarTypeArrayListH2 extends ScalarTypeArrayList {
|
|||||||
if (nullable) {
|
if (nullable) {
|
||||||
binder.setNull(Types.ARRAY);
|
binder.setNull(Types.ARRAY);
|
||||||
} else {
|
} else {
|
||||||
binder.setObject(toArray(EMPTY_LIST));
|
binder.setObject(EMPTY_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,16 +15,9 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import static java.util.Collections.EMPTY_SET;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type mapped for DB ARRAY type (Postgres only effectively).
|
* Type mapped for DB ARRAY type (Postgres only effectively).
|
||||||
*/
|
*/
|
||||||
@@ -125,7 +118,7 @@ class ScalarTypeArraySet extends ScalarTypeArrayBase<Set> implements ScalarTypeA
|
|||||||
if (nullable) {
|
if (nullable) {
|
||||||
binder.setNull(Types.ARRAY);
|
binder.setNull(Types.ARRAY);
|
||||||
} else {
|
} else {
|
||||||
binder.setArray(arrayType, toArray(EMPTY_SET));
|
binder.setArray(arrayType, EMPTY_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import static java.util.Collections.EMPTY_SET;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* H2 database support for DB ARRAY.
|
* H2 database support for DB ARRAY.
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +82,7 @@ final class ScalarTypeArraySetH2 extends ScalarTypeArraySet {
|
|||||||
if (nullable) {
|
if (nullable) {
|
||||||
binder.setNull(Types.ARRAY);
|
binder.setNull(Types.ARRAY);
|
||||||
} else {
|
} else {
|
||||||
binder.setObject(toArray(EMPTY_SET));
|
binder.setObject(EMPTY_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user