mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2318 - Refactor internals - final classes in type packages
This commit is contained in:
1 parent
dde9b507ce
commit
7521cb530e
65 files changed
+149
-253
No files matched your search
@@ -6,16 +6,8 @@ import io.ebean.RawSqlBuilder;
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.config.BeanNotEnhancedException;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.EncryptKey;
|
||||
import io.ebean.config.EncryptKeyManager;
|
||||
import io.ebean.config.NamingConvention;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DbHistorySupport;
|
||||
import io.ebean.config.dbplatform.DbIdentity;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
import io.ebean.config.*;
|
||||
import io.ebean.config.dbplatform.*;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebean.event.changelog.ChangeLogFilter;
|
||||
import io.ebean.event.changelog.ChangeLogListener;
|
||||
@@ -36,26 +28,12 @@ import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||
import io.ebeaninternal.server.deploy.id.IdBinder;
|
||||
import io.ebeaninternal.server.deploy.id.IdBinderEmbedded;
|
||||
import io.ebeaninternal.server.deploy.id.IdBinderFactory;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssoc;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocMany;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanTable;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployIdentityMode;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployOrderColumn;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployTableJoin;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployCreateProperties;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployInherit;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployUtil;
|
||||
import io.ebeaninternal.server.deploy.parse.ReadAnnotations;
|
||||
import io.ebeaninternal.server.deploy.parse.TransientProperties;
|
||||
import io.ebeaninternal.server.deploy.meta.*;
|
||||
import io.ebeaninternal.server.deploy.parse.*;
|
||||
import io.ebeaninternal.server.persist.platform.MultiValueBind;
|
||||
import io.ebeaninternal.server.properties.BeanPropertiesReader;
|
||||
import io.ebeaninternal.server.properties.BeanPropertyAccess;
|
||||
import io.ebeaninternal.server.properties.EnhanceBeanPropertyAccess;
|
||||
import io.ebeaninternal.server.type.ScalarTypeInteger;
|
||||
import io.ebeaninternal.server.type.TypeManager;
|
||||
import io.ebeaninternal.xmapping.api.XmapEbean;
|
||||
import io.ebeaninternal.xmapping.api.XmapEntity;
|
||||
@@ -73,14 +51,7 @@ import javax.sql.DataSource;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -905,7 +876,8 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
|
||||
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
|
||||
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, ScalarTypeInteger.INSTANCE, null);
|
||||
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
|
||||
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, scalarType, null);
|
||||
orderProperty.setName(DeployOrderColumn.LOGICAL_NAME);
|
||||
orderProperty.setDbColumn(orderColumn.getName());
|
||||
orderProperty.setNullable(orderColumn.isNullable());
|
||||
|
||||
@@ -82,9 +82,7 @@ final class AnnotationFields extends AnnotationParser {
|
||||
* If present read Jackson JsonIgnore.
|
||||
*/
|
||||
private final boolean jacksonAnnotationsPresent;
|
||||
|
||||
private final GeneratedPropertyFactory generatedPropFactory;
|
||||
|
||||
/**
|
||||
* By default we lazy load Lob properties.
|
||||
*/
|
||||
@@ -118,20 +116,16 @@ final class AnnotationFields extends AnnotationParser {
|
||||
* Read the Id marker annotations on EmbeddedId properties.
|
||||
*/
|
||||
private void readAssocOne(DeployBeanPropertyAssoc<?> prop) {
|
||||
|
||||
readJsonAnnotations(prop);
|
||||
|
||||
if (has(prop, Id.class)) {
|
||||
readIdAssocOne(prop);
|
||||
}
|
||||
|
||||
if (has(prop, EmbeddedId.class)) {
|
||||
prop.setId();
|
||||
prop.setNullable(false);
|
||||
prop.setEmbedded();
|
||||
info.setEmbeddedId(prop);
|
||||
}
|
||||
|
||||
DocEmbedded docEmbedded = get(prop, DocEmbedded.class);
|
||||
if (docEmbedded != null) {
|
||||
prop.setDocStoreEmbedded(docEmbedded.doc());
|
||||
@@ -143,19 +137,16 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prop instanceof DeployBeanPropertyAssocOne<?>) {
|
||||
if (prop.isId() && !prop.isEmbedded()) {
|
||||
prop.setEmbedded();
|
||||
}
|
||||
readEmbeddedAttributeOverrides((DeployBeanPropertyAssocOne<?>) prop);
|
||||
}
|
||||
|
||||
Formula formula = prop.getMetaAnnotationFormula(platform);
|
||||
if (formula != null) {
|
||||
prop.setSqlFormula(processFormula(formula.select()), processFormula(formula.join()));
|
||||
}
|
||||
|
||||
initWhoProperties(prop);
|
||||
initDbMigration(prop);
|
||||
}
|
||||
@@ -170,32 +161,26 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
|
||||
private void readField(DeployBeanProperty prop) {
|
||||
|
||||
// all Enums will have a ScalarType assigned...
|
||||
boolean isEnum = prop.getPropertyType().isEnum();
|
||||
Enumerated enumerated = get(prop, Enumerated.class);
|
||||
if (isEnum || enumerated != null) {
|
||||
util.setEnumScalarType(enumerated, prop);
|
||||
}
|
||||
|
||||
// its persistent and assumed to be on the base table
|
||||
// rather than on a secondary table
|
||||
prop.setDbRead(true);
|
||||
prop.setDbInsertable(true);
|
||||
prop.setDbUpdateable(true);
|
||||
|
||||
Column column = prop.getMetaAnnotation(Column.class);
|
||||
if (column != null) {
|
||||
readColumn(column, prop);
|
||||
}
|
||||
|
||||
readJsonAnnotations(prop);
|
||||
|
||||
if (prop.getDbColumn() == null) {
|
||||
// No @Column or @Column.name() so use NamingConvention
|
||||
prop.setDbColumn(namingConvention.getColumnFromProperty(beanType, prop.getName()));
|
||||
}
|
||||
|
||||
initIdentity(prop);
|
||||
initTenantId(prop);
|
||||
initDbJson(prop);
|
||||
@@ -204,7 +189,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
initWhen(prop);
|
||||
initWhoProperties(prop);
|
||||
initDbMigration(prop);
|
||||
|
||||
// Want to process last so we can use with @Formula
|
||||
if (has(prop, Transient.class)) {
|
||||
// it is not a persistent property.
|
||||
@@ -213,9 +197,7 @@ final class AnnotationFields extends AnnotationParser {
|
||||
prop.setDbUpdateable(false);
|
||||
prop.setTransient();
|
||||
}
|
||||
|
||||
initEncrypt(prop);
|
||||
|
||||
for (Index index : annotationIndexes(prop)) {
|
||||
addIndex(prop, index);
|
||||
}
|
||||
@@ -234,22 +216,18 @@ final class AnnotationFields extends AnnotationParser {
|
||||
if (identity != null) {
|
||||
readIdentity(identity);
|
||||
}
|
||||
|
||||
// determine the JDBC type using Lob/Temporal
|
||||
// otherwise based on the property Class
|
||||
Temporal temporal = get(prop, Temporal.class);
|
||||
if (temporal != null) {
|
||||
readTemporal(temporal, prop);
|
||||
|
||||
} else if (has(prop, Lob.class)) {
|
||||
util.setLobType(prop);
|
||||
}
|
||||
|
||||
Length length = get(prop, Length.class);
|
||||
if (length != null) {
|
||||
prop.setDbLength(length.value());
|
||||
}
|
||||
|
||||
if (has(prop, io.ebean.annotation.NotNull.class)) {
|
||||
prop.setNullable(false);
|
||||
}
|
||||
@@ -336,7 +314,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
if (formula != null) {
|
||||
prop.setSqlFormula(processFormula(formula.select()), processFormula(formula.join()));
|
||||
}
|
||||
|
||||
final Aggregation aggregation = prop.getMetaAnnotation(Aggregation.class);
|
||||
if (aggregation != null) {
|
||||
prop.setAggregation(aggregation.value().replace("$1", prop.getName()));
|
||||
@@ -349,7 +326,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
prop.setVersionColumn();
|
||||
generatedPropFactory.setVersion(prop);
|
||||
}
|
||||
|
||||
Basic basic = get(prop, Basic.class);
|
||||
if (basic != null) {
|
||||
prop.setFetchType(basic.fetch());
|
||||
@@ -397,7 +373,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
if (dbDefault != null) {
|
||||
prop.setDbColumnDefault(dbDefault.value());
|
||||
}
|
||||
|
||||
Set<DbMigration> dbMigration = annotationDbMigrations(prop);
|
||||
dbMigration.forEach(ann -> prop.addDbMigrationInfo(
|
||||
new DbMigrationInfo(ann.preAdd(), ann.postAdd(), ann.preAlter(), ann.postAlter(), ann.platforms())));
|
||||
@@ -423,7 +398,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
throw new RuntimeException("DB-columname has to be specified exactly one time in columnNames.");
|
||||
}
|
||||
}
|
||||
|
||||
if (columnNames.length == 1 && hasRelationshipItem(prop)) {
|
||||
throw new RuntimeException("Can't use Index on foreign key relationships.");
|
||||
}
|
||||
@@ -438,13 +412,11 @@ final class AnnotationFields extends AnnotationParser {
|
||||
prop.setJsonDeserialize(!jsonIgnore.value());
|
||||
}
|
||||
}
|
||||
|
||||
Expose expose = get(prop, Expose.class);
|
||||
if (expose != null) {
|
||||
prop.setJsonSerialize(expose.serialize());
|
||||
prop.setJsonDeserialize(expose.deserialize());
|
||||
}
|
||||
|
||||
JsonIgnore jsonIgnore = get(prop, JsonIgnore.class);
|
||||
if (jsonIgnore != null) {
|
||||
prop.setJsonSerialize(jsonIgnore.serialize());
|
||||
@@ -460,9 +432,7 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
|
||||
private void setEncryption(DeployBeanProperty prop, boolean dbEncString, int dbLen) {
|
||||
|
||||
util.checkEncryptKeyManagerDefined(prop.getFullBeanName());
|
||||
|
||||
ScalarType<?> st = prop.getScalarType();
|
||||
if (byte[].class.equals(st.getType())) {
|
||||
// Always using Java client encryption rather than DB for encryption
|
||||
@@ -474,12 +444,9 @@ final class AnnotationFields extends AnnotationParser {
|
||||
prop.setScalarType(encryptedScalarType);
|
||||
prop.setLocalEncrypted();
|
||||
return;
|
||||
|
||||
}
|
||||
if (dbEncString) {
|
||||
|
||||
DbEncrypt dbEncrypt = util.getDbPlatform().getDbEncrypt();
|
||||
|
||||
if (dbEncrypt != null) {
|
||||
// check if we have a DB encryption function for this type
|
||||
int jdbcType = prop.getScalarType().getJdbcType();
|
||||
@@ -491,7 +458,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prop.setScalarType(createScalarType(prop, st));
|
||||
prop.setLocalEncrypted();
|
||||
if (dbLen > 0) {
|
||||
@@ -501,11 +467,9 @@ final class AnnotationFields extends AnnotationParser {
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private ScalarTypeEncryptedWrapper<?> createScalarType(DeployBeanProperty prop, ScalarType<?> st) {
|
||||
|
||||
// Use Java Encryptor wrapping the logical scalar type
|
||||
DataEncryptSupport support = createDataEncryptSupport(prop);
|
||||
ScalarTypeBytesBase byteType = getDbEncryptType(prop);
|
||||
|
||||
return new ScalarTypeEncryptedWrapper(st, byteType, support);
|
||||
}
|
||||
|
||||
@@ -515,10 +479,8 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
|
||||
private DataEncryptSupport createDataEncryptSupport(DeployBeanProperty prop) {
|
||||
|
||||
String table = info.getDescriptor().getBaseTable();
|
||||
String column = prop.getDbColumn();
|
||||
|
||||
return util.createDataEncryptSupport(table, column);
|
||||
}
|
||||
|
||||
@@ -530,7 +492,6 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
}
|
||||
descriptor.setIdGeneratedValue();
|
||||
|
||||
SequenceGenerator seq = get(prop, SequenceGenerator.class);
|
||||
if (seq != null) {
|
||||
String seqName = seq.sequenceName();
|
||||
@@ -543,13 +504,11 @@ final class AnnotationFields extends AnnotationParser {
|
||||
GenerationType strategy = gen.strategy();
|
||||
if (strategy == GenerationType.IDENTITY) {
|
||||
descriptor.setIdentityType(IdType.IDENTITY);
|
||||
|
||||
} else if (strategy == GenerationType.SEQUENCE) {
|
||||
descriptor.setIdentityType(IdType.SEQUENCE);
|
||||
if (!gen.generator().isEmpty()) {
|
||||
descriptor.setIdentitySequenceGenerator(gen.generator());
|
||||
}
|
||||
|
||||
} else if (strategy == GenerationType.AUTO) {
|
||||
if (!gen.generator().isEmpty()) {
|
||||
// use a custom IdGenerator
|
||||
@@ -565,21 +524,16 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
|
||||
private void readTemporal(Temporal temporal, DeployBeanProperty prop) {
|
||||
|
||||
TemporalType type = temporal.value();
|
||||
if (type == TemporalType.DATE) {
|
||||
prop.setDbType(Types.DATE);
|
||||
|
||||
} else if (type == TemporalType.TIMESTAMP) {
|
||||
prop.setDbType(Types.TIMESTAMP);
|
||||
|
||||
} else if (type == TemporalType.TIME) {
|
||||
prop.setDbType(Types.TIME);
|
||||
|
||||
} else {
|
||||
throw new PersistenceException("Unhandled type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -112,7 +112,7 @@ import java.util.regex.Pattern;
|
||||
* @author Erik Kline
|
||||
* @since 5
|
||||
*/
|
||||
public final class ConvertInetAddresses {
|
||||
final class ConvertInetAddresses {
|
||||
|
||||
private static final int IPV4_PART_COUNT = 4;
|
||||
private static final int IPV6_PART_COUNT = 8;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.time.Instant;
|
||||
* @author Nick Williams
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public final class DecimalUtils {
|
||||
final class DecimalUtils {
|
||||
|
||||
private static final char[] ZEROES = new char[]{'0', '0', '0', '0', '0', '0', '0', '0', '0'};
|
||||
|
||||
@@ -37,17 +37,17 @@ public final class DecimalUtils {
|
||||
throw new RuntimeException("DecimalUtils cannot be instantiated.");
|
||||
}
|
||||
|
||||
public static Duration toDuration(BigDecimal value) {
|
||||
static Duration toDuration(BigDecimal value) {
|
||||
long seconds = value.longValue();
|
||||
int nanoseconds = extractNanosecondDecimal(value, seconds);
|
||||
return Duration.ofSeconds(seconds, nanoseconds);
|
||||
}
|
||||
|
||||
public static BigDecimal toDecimal(Duration instant) {
|
||||
static BigDecimal toDecimal(Duration instant) {
|
||||
return new BigDecimal(toDecimal(instant.getSeconds(), instant.getNano()));
|
||||
}
|
||||
|
||||
public static Timestamp toTimestamp(BigDecimal value) {
|
||||
static Timestamp toTimestamp(BigDecimal value) {
|
||||
long seconds = value.longValue();
|
||||
int nanoseconds = extractNanosecondDecimal(value, seconds);
|
||||
Timestamp ts = new Timestamp(seconds * 1000);
|
||||
@@ -55,30 +55,30 @@ public final class DecimalUtils {
|
||||
return ts;
|
||||
}
|
||||
|
||||
public static BigDecimal toDecimal(Timestamp instant) {
|
||||
static BigDecimal toDecimal(Timestamp instant) {
|
||||
long millis = instant.getTime();
|
||||
long secs = millis / 1000;
|
||||
return new BigDecimal(toDecimal(secs, instant.getNanos()));
|
||||
}
|
||||
|
||||
public static Instant toInstant(BigDecimal value) {
|
||||
static Instant toInstant(BigDecimal value) {
|
||||
long seconds = value.longValue();
|
||||
int nanoseconds = extractNanosecondDecimal(value, seconds);
|
||||
return Instant.ofEpochSecond(seconds, nanoseconds);
|
||||
}
|
||||
|
||||
public static BigDecimal toDecimal(Instant instant) {
|
||||
static BigDecimal toDecimal(Instant instant) {
|
||||
return new BigDecimal(toDecimal(instant.getEpochSecond(), instant.getNano()));
|
||||
}
|
||||
|
||||
public static String toDecimal(long seconds, int nanoseconds) {
|
||||
static String toDecimal(long seconds, int nanoseconds) {
|
||||
StringBuilder string = new StringBuilder(Integer.toString(nanoseconds));
|
||||
if (string.length() < 9)
|
||||
string.insert(0, ZEROES, 0, 9 - string.length());
|
||||
return seconds + "." + string;
|
||||
}
|
||||
|
||||
public static int extractNanosecondDecimal(BigDecimal value, long integer) {
|
||||
static int extractNanosecondDecimal(BigDecimal value, long integer) {
|
||||
return value.subtract(new BigDecimal(integer)).multiply(ONE_BILLION).intValue();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.Date;
|
||||
* Helper to create some default ScalarType objects for Booleans,
|
||||
* java.util.Date, java.util.Calendar etc.
|
||||
*/
|
||||
public final class DefaultTypeFactory {
|
||||
final class DefaultTypeFactory {
|
||||
|
||||
private final DatabaseConfig config;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
private final ScalarType<?> varbinaryType = new ScalarTypeBytesVarbinary();
|
||||
private final ScalarType<?> longVarbinaryType = new ScalarTypeBytesLongVarbinary();
|
||||
private final ScalarType<?> shortType = new ScalarTypeShort();
|
||||
private final ScalarType<?> integerType = ScalarTypeInteger.INSTANCE;
|
||||
private final ScalarType<?> integerType = new ScalarTypeInteger();
|
||||
private final ScalarType<?> longType = new ScalarTypeLong();
|
||||
private final ScalarType<?> doubleType = new ScalarTypeDouble();
|
||||
private final ScalarType<?> floatType = new ScalarTypeFloat();
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* Used to map enum values to database integer values.
|
||||
*/
|
||||
public final class EnumToDbIntegerMap extends EnumToDbValueMap<Integer> {
|
||||
final class EnumToDbIntegerMap extends EnumToDbValueMap<Integer> {
|
||||
|
||||
@Override
|
||||
public int getDbType() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* Used to map Enum values to database string/varchar values.
|
||||
*/
|
||||
public final class EnumToDbStringMap extends EnumToDbValueMap<String> {
|
||||
final class EnumToDbStringMap extends EnumToDbValueMap<String> {
|
||||
|
||||
@Override
|
||||
public int getDbType() {
|
||||
|
||||
@@ -15,9 +15,9 @@ import java.util.LinkedHashMap;
|
||||
* Enum gets converter to.
|
||||
* </p>
|
||||
*/
|
||||
public abstract class EnumToDbValueMap<T> {
|
||||
abstract class EnumToDbValueMap<T> {
|
||||
|
||||
public static EnumToDbValueMap<?> create(boolean integerType) {
|
||||
static EnumToDbValueMap<?> create(boolean integerType) {
|
||||
return integerType ? new EnumToDbIntegerMap() : new EnumToDbStringMap();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class EnumToDbValueMap<T> {
|
||||
/**
|
||||
* Construct with allowNulls defaulting to false.
|
||||
*/
|
||||
public EnumToDbValueMap() {
|
||||
EnumToDbValueMap() {
|
||||
this(false, false);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class EnumToDbValueMap<T> {
|
||||
* value is found.
|
||||
* </p>
|
||||
*/
|
||||
public EnumToDbValueMap(boolean allowNulls, boolean isIntegerType) {
|
||||
EnumToDbValueMap(boolean allowNulls, boolean isIntegerType) {
|
||||
this.allowNulls = allowNulls;
|
||||
this.isIntegerType = isIntegerType;
|
||||
this.keyMap = new LinkedHashMap<>();
|
||||
@@ -54,7 +54,7 @@ public abstract class EnumToDbValueMap<T> {
|
||||
* Return true if this is mapping to integers, false
|
||||
* if mapping to Strings.
|
||||
*/
|
||||
public boolean isIntegerType() {
|
||||
boolean isIntegerType() {
|
||||
return isIntegerType;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.ScalarTypeConverter;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public final class LongToTimestampConverter implements ScalarTypeConverter<Long, Timestamp> {
|
||||
|
||||
@Override
|
||||
public Long getNullValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp unwrapValue(Long beanType) {
|
||||
return new Timestamp(beanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long wrapValue(Timestamp scalarType) {
|
||||
return scalarType.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,14 +9,14 @@ public final class PostgresHelper {
|
||||
/**
|
||||
* The Postgres JSON DB type.
|
||||
*/
|
||||
public static final String JSON_TYPE = "json";
|
||||
static final String JSON_TYPE = "json";
|
||||
|
||||
/**
|
||||
* The Postgres JSONB DB type.
|
||||
*/
|
||||
public static final String JSONB_TYPE = "jsonb";
|
||||
static final String JSONB_TYPE = "jsonb";
|
||||
|
||||
public static final String INET_TYPE = "inet";
|
||||
static final String INET_TYPE = "inet";
|
||||
|
||||
public static Object asInet(String value) throws SQLException {
|
||||
return asObject(INET_TYPE, value);
|
||||
|
||||
@@ -28,7 +28,7 @@ import static java.util.Collections.EMPTY_LIST;
|
||||
* Type mapped for DB ARRAY type (Postgres only effectively).
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ScalarTypeArrayList extends ScalarTypeArrayBase<List> implements ScalarTypeArray {
|
||||
class ScalarTypeArrayList extends ScalarTypeArrayBase<List> implements ScalarTypeArray {
|
||||
|
||||
static PlatformArrayTypeFactory factory() {
|
||||
return new Factory();
|
||||
|
||||
@@ -29,7 +29,7 @@ import static java.util.Collections.EMPTY_SET;
|
||||
* Type mapped for DB ARRAY type (Postgres only effectively).
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class ScalarTypeArraySet extends ScalarTypeArrayBase<Set> implements ScalarTypeArray {
|
||||
class ScalarTypeArraySet extends ScalarTypeArrayBase<Set> implements ScalarTypeArray {
|
||||
|
||||
static PlatformArrayTypeFactory factory() {
|
||||
return new Factory();
|
||||
|
||||
@@ -6,15 +6,13 @@ import io.ebean.core.type.ScalarType;
|
||||
/**
|
||||
* Base ScalarType object.
|
||||
*/
|
||||
public abstract class ScalarTypeBase<T> implements ScalarType<T> {
|
||||
abstract class ScalarTypeBase<T> implements ScalarType<T> {
|
||||
|
||||
protected final Class<T> type;
|
||||
|
||||
protected final boolean jdbcNative;
|
||||
|
||||
protected final int jdbcType;
|
||||
|
||||
public ScalarTypeBase(Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
ScalarTypeBase(Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
this.type = type;
|
||||
this.jdbcNative = jdbcNative;
|
||||
this.jdbcType = jdbcType;
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* Base class for Date types.
|
||||
*/
|
||||
public abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
|
||||
abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
|
||||
|
||||
protected final JsonConfig.Date mode;
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ import static io.ebeaninternal.server.type.IsoJsonDateTimeParser.parseIso;
|
||||
/**
|
||||
* Base type for DateTime types.
|
||||
*/
|
||||
public abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
|
||||
abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
|
||||
|
||||
protected final JsonConfig.DateTime mode;
|
||||
|
||||
public ScalarTypeBaseDateTime(JsonConfig.DateTime mode, Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
ScalarTypeBaseDateTime(JsonConfig.DateTime mode, Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
super(type, jdbcNative, jdbcType);
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ import java.sql.Types;
|
||||
* Base ScalarType for types which converts to and from a VARCHAR database
|
||||
* column.
|
||||
*/
|
||||
public abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
|
||||
abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
|
||||
|
||||
public ScalarTypeBaseVarchar(Class<T> type) {
|
||||
ScalarTypeBaseVarchar(Class<T> type) {
|
||||
super(type, false, Types.VARCHAR);
|
||||
}
|
||||
|
||||
public ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType) {
|
||||
super(type, jdbcNative, jdbcType);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for BigDecimal.
|
||||
*/
|
||||
public class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
||||
class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
||||
|
||||
public ScalarTypeBigDecimal() {
|
||||
ScalarTypeBigDecimal() {
|
||||
super(BigDecimal.class, true, Types.DECIMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Byte.
|
||||
*/
|
||||
public final class ScalarTypeByte extends ScalarTypeBase<Byte> {
|
||||
final class ScalarTypeByte extends ScalarTypeBase<Byte> {
|
||||
|
||||
public ScalarTypeByte() {
|
||||
super(Byte.class, true, Types.TINYINT);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public abstract class ScalarTypeBytesBase extends ScalarTypeBase<byte[]> {
|
||||
|
||||
protected ScalarTypeBytesBase(boolean jdbcNative, int jdbcType) {
|
||||
ScalarTypeBytesBase(boolean jdbcNative, int jdbcType) {
|
||||
super(byte[].class, jdbcNative, jdbcType);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Types.BINARY to byte[].
|
||||
*/
|
||||
public final class ScalarTypeBytesBinary extends ScalarTypeBytesBase {
|
||||
final class ScalarTypeBytesBinary extends ScalarTypeBytesBase {
|
||||
|
||||
public ScalarTypeBytesBinary() {
|
||||
ScalarTypeBytesBinary() {
|
||||
super(true, Types.BINARY);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for BLOB.
|
||||
*/
|
||||
public final class ScalarTypeBytesBlob extends ScalarTypeBytesBase {
|
||||
final class ScalarTypeBytesBlob extends ScalarTypeBytesBase {
|
||||
|
||||
public ScalarTypeBytesBlob() {
|
||||
ScalarTypeBytesBlob() {
|
||||
super(true, Types.BLOB);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Longvarbinary.
|
||||
*/
|
||||
public final class ScalarTypeBytesLongVarbinary extends ScalarTypeBytesBase {
|
||||
final class ScalarTypeBytesLongVarbinary extends ScalarTypeBytesBase {
|
||||
|
||||
public ScalarTypeBytesLongVarbinary() {
|
||||
ScalarTypeBytesLongVarbinary() {
|
||||
super(true, Types.LONGVARBINARY);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Types.VARBINARY to byte[].
|
||||
*/
|
||||
public final class ScalarTypeBytesVarbinary extends ScalarTypeBytesBase {
|
||||
final class ScalarTypeBytesVarbinary extends ScalarTypeBytesBase {
|
||||
|
||||
public ScalarTypeBytesVarbinary() {
|
||||
ScalarTypeBytesVarbinary() {
|
||||
super(true, Types.VARBINARY);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import static io.ebeaninternal.server.type.IsoJsonDateTimeParser.formatIso;
|
||||
/**
|
||||
* ScalarType for java.util.Calendar.
|
||||
*/
|
||||
public final class ScalarTypeCalendar extends ScalarTypeBaseDateTime<Calendar> {
|
||||
final class ScalarTypeCalendar extends ScalarTypeBaseDateTime<Calendar> {
|
||||
|
||||
public ScalarTypeCalendar(JsonConfig.DateTime mode, int jdbcType) {
|
||||
ScalarTypeCalendar(JsonConfig.DateTime mode, int jdbcType) {
|
||||
super(mode, Calendar.class, false, jdbcType);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for char.
|
||||
*/
|
||||
public final class ScalarTypeChar extends ScalarTypeBaseVarchar<Character> {
|
||||
final class ScalarTypeChar extends ScalarTypeBaseVarchar<Character> {
|
||||
|
||||
public ScalarTypeChar() {
|
||||
ScalarTypeChar() {
|
||||
super(char.class, false, Types.VARCHAR);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for char[].
|
||||
*/
|
||||
public final class ScalarTypeCharArray extends ScalarTypeBaseVarchar<char[]> {
|
||||
final class ScalarTypeCharArray extends ScalarTypeBaseVarchar<char[]> {
|
||||
|
||||
public ScalarTypeCharArray() {
|
||||
ScalarTypeCharArray() {
|
||||
super(char[].class, false, Types.VARCHAR);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Cidr to Varchar or Postgres CIDR.
|
||||
*/
|
||||
public abstract class ScalarTypeCidr extends ScalarTypeBaseVarchar<Cidr> {
|
||||
abstract class ScalarTypeCidr extends ScalarTypeBaseVarchar<Cidr> {
|
||||
|
||||
ScalarTypeCidr() {
|
||||
super(Cidr.class, false, ExtraDbTypes.CIDR);
|
||||
@@ -42,7 +42,7 @@ public abstract class ScalarTypeCidr extends ScalarTypeBaseVarchar<Cidr> {
|
||||
/**
|
||||
* Cidr to Varchar.
|
||||
*/
|
||||
public static final class Varchar extends ScalarTypeCidr {
|
||||
static final class Varchar extends ScalarTypeCidr {
|
||||
|
||||
@Override
|
||||
public void bind(DataBinder binder, Cidr value) throws SQLException {
|
||||
@@ -57,7 +57,7 @@ public abstract class ScalarTypeCidr extends ScalarTypeBaseVarchar<Cidr> {
|
||||
/**
|
||||
* Cidr to Postgres CIDR.
|
||||
*/
|
||||
public static final class Postgres extends ScalarTypeCidr {
|
||||
static final class Postgres extends ScalarTypeCidr {
|
||||
|
||||
@Override
|
||||
public void bind(DataBinder binder, Cidr value) throws SQLException {
|
||||
|
||||
@@ -6,7 +6,7 @@ import javax.persistence.PersistenceException;
|
||||
* ScalarType for Class that persists it to VARCHAR column.
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
public final class ScalarTypeClass extends ScalarTypeBaseVarchar<Class> {
|
||||
final class ScalarTypeClass extends ScalarTypeBaseVarchar<Class> {
|
||||
|
||||
public ScalarTypeClass() {
|
||||
super(Class.class);
|
||||
|
||||
@@ -8,13 +8,13 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for String.
|
||||
*/
|
||||
public class ScalarTypeClob extends ScalarTypeStringBase {
|
||||
class ScalarTypeClob extends ScalarTypeStringBase {
|
||||
|
||||
ScalarTypeClob(boolean jdbcNative, int jdbcType) {
|
||||
super(jdbcNative, jdbcType);
|
||||
}
|
||||
|
||||
public ScalarTypeClob() {
|
||||
ScalarTypeClob() {
|
||||
super(true, Types.CLOB);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.Currency;
|
||||
/**
|
||||
* ScalarType for java.util.Currency which converts to and from a VARCHAR database column.
|
||||
*/
|
||||
public final class ScalarTypeCurrency extends ScalarTypeBaseVarchar<Currency> {
|
||||
final class ScalarTypeCurrency extends ScalarTypeBaseVarchar<Currency> {
|
||||
|
||||
public ScalarTypeCurrency() {
|
||||
ScalarTypeCurrency() {
|
||||
super(Currency.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for java.sql.Date.
|
||||
*/
|
||||
public final class ScalarTypeDate extends ScalarTypeBaseDate<java.sql.Date> {
|
||||
final class ScalarTypeDate extends ScalarTypeBaseDate<java.sql.Date> {
|
||||
|
||||
public ScalarTypeDate(JsonConfig.Date mode) {
|
||||
ScalarTypeDate(JsonConfig.Date mode) {
|
||||
super(mode, Date.class, true, Types.DATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.time.DayOfWeek;
|
||||
/**
|
||||
* ScalarType mapping for Month enum.
|
||||
*/
|
||||
public final class ScalarTypeDayOfWeek extends ScalarTypeEnumWithMapping {
|
||||
final class ScalarTypeDayOfWeek extends ScalarTypeEnumWithMapping {
|
||||
|
||||
static final EnumToDbIntegerMap beanDbMap = new EnumToDbIntegerMap();
|
||||
|
||||
@@ -22,7 +22,7 @@ public final class ScalarTypeDayOfWeek extends ScalarTypeEnumWithMapping {
|
||||
}
|
||||
}
|
||||
|
||||
public ScalarTypeDayOfWeek() {
|
||||
ScalarTypeDayOfWeek() {
|
||||
super(beanDbMap, DayOfWeek.class, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Double and double.
|
||||
*/
|
||||
public final class ScalarTypeDouble extends ScalarTypeBase<Double> {
|
||||
final class ScalarTypeDouble extends ScalarTypeBase<Double> {
|
||||
|
||||
public ScalarTypeDouble() {
|
||||
ScalarTypeDouble() {
|
||||
super(Double.class, true, Types.DOUBLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,21 +19,21 @@ import java.time.Duration;
|
||||
/**
|
||||
* ScalarType for java.time.Duration (with seconds precision).
|
||||
*/
|
||||
public class ScalarTypeDuration extends ScalarTypeBase<Duration> {
|
||||
class ScalarTypeDuration extends ScalarTypeBase<Duration> {
|
||||
|
||||
public ScalarTypeDuration() {
|
||||
ScalarTypeDuration() {
|
||||
super(Duration.class, false, Types.BIGINT);
|
||||
}
|
||||
|
||||
protected ScalarTypeDuration(int jdbcType) {
|
||||
ScalarTypeDuration(int jdbcType) {
|
||||
super(Duration.class, false, jdbcType);
|
||||
}
|
||||
|
||||
public BigDecimal convertToBigDecimal(Duration value) {
|
||||
BigDecimal convertToBigDecimal(Duration value) {
|
||||
return (value == null) ? null : DecimalUtils.toDecimal(value);
|
||||
}
|
||||
|
||||
public Duration convertFromBigDecimal(BigDecimal value) {
|
||||
Duration convertFromBigDecimal(BigDecimal value) {
|
||||
return (value == null) ? null : DecimalUtils.toDuration(value);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@ import java.time.Duration;
|
||||
* Stored in the DB as DECIMAL value.
|
||||
* </p>
|
||||
*/
|
||||
public final class ScalarTypeDurationWithNanos extends ScalarTypeDuration {
|
||||
final class ScalarTypeDurationWithNanos extends ScalarTypeDuration {
|
||||
|
||||
public ScalarTypeDurationWithNanos() {
|
||||
ScalarTypeDurationWithNanos() {
|
||||
super(Types.DECIMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,17 +28,17 @@ import java.util.Set;
|
||||
* Ebean specific @EnumMapping.
|
||||
* </p>
|
||||
*/
|
||||
public final class ScalarTypeEnumStandard {
|
||||
final class ScalarTypeEnumStandard {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static final class StringEnum extends EnumBase implements ScalarTypeEnum {
|
||||
static final class StringEnum extends EnumBase implements ScalarTypeEnum {
|
||||
|
||||
private final int length;
|
||||
|
||||
/**
|
||||
* Create a ScalarTypeEnum.
|
||||
*/
|
||||
public StringEnum(Class enumType) {
|
||||
StringEnum(Class enumType) {
|
||||
super(enumType, false, Types.VARCHAR);
|
||||
this.length = maxValueLength(enumType);
|
||||
}
|
||||
@@ -117,14 +117,14 @@ public final class ScalarTypeEnumStandard {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static final class OrdinalEnum extends EnumBase implements ScalarTypeEnum {
|
||||
static final class OrdinalEnum extends EnumBase implements ScalarTypeEnum {
|
||||
|
||||
private final Object[] enumArray;
|
||||
|
||||
/**
|
||||
* Create a ScalarTypeEnum.
|
||||
*/
|
||||
public OrdinalEnum(Class enumType) {
|
||||
OrdinalEnum(Class enumType) {
|
||||
super(enumType, false, Types.INTEGER);
|
||||
this.enumArray = EnumSet.allOf(enumType).toArray();
|
||||
}
|
||||
@@ -200,11 +200,11 @@ public final class ScalarTypeEnumStandard {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public abstract static class EnumBase extends ScalarTypeBase {
|
||||
abstract static class EnumBase extends ScalarTypeBase {
|
||||
|
||||
protected final Class enumType;
|
||||
|
||||
public EnumBase(Class<?> type, boolean jdbcNative, int jdbcType) {
|
||||
EnumBase(Class<?> type, boolean jdbcNative, int jdbcType) {
|
||||
super(type, jdbcNative, jdbcType);
|
||||
this.enumType = type;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ import java.util.Set;
|
||||
* Additional control over mapping to DB values.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase implements ScalarType, ScalarTypeEnum {
|
||||
class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase implements ScalarType, ScalarTypeEnum {
|
||||
|
||||
private final EnumToDbValueMap beanDbMap;
|
||||
private final int length;
|
||||
@@ -23,14 +23,14 @@ public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase i
|
||||
/**
|
||||
* Create with an explicit mapping of bean to database values.
|
||||
*/
|
||||
public ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length, boolean withConstraint) {
|
||||
ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length, boolean withConstraint) {
|
||||
super(enumType, false, beanDbMap.getDbType());
|
||||
this.beanDbMap = beanDbMap;
|
||||
this.length = length;
|
||||
this.withConstraint = withConstraint;
|
||||
}
|
||||
|
||||
public ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length) {
|
||||
ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length) {
|
||||
this(beanDbMap, enumType, length, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for streaming between a File and the database.
|
||||
*/
|
||||
public final class ScalarTypeFile extends ScalarTypeBase<File> {
|
||||
final class ScalarTypeFile extends ScalarTypeBase<File> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScalarTypeFile.class);
|
||||
|
||||
@@ -37,14 +37,14 @@ public final class ScalarTypeFile extends ScalarTypeBase<File> {
|
||||
/**
|
||||
* Construct with reasonable defaults of Blob and 8096 buffer size.
|
||||
*/
|
||||
public ScalarTypeFile() {
|
||||
ScalarTypeFile() {
|
||||
this(Types.LONGVARBINARY, "db-", null, null, 8096);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ScalarTypeFile.
|
||||
*/
|
||||
public ScalarTypeFile(int jdbcType, String prefix, String suffix, File directory, int bufferSize) {
|
||||
ScalarTypeFile(int jdbcType, String prefix, String suffix, File directory, int bufferSize) {
|
||||
super(File.class, false, jdbcType);
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
@@ -73,15 +73,12 @@ public final class ScalarTypeFile extends ScalarTypeBase<File> {
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// stream from db into our temp file
|
||||
File tempFile = File.createTempFile(prefix, suffix, directory);
|
||||
OutputStream os = getOutputStream(tempFile);
|
||||
pump(is, os);
|
||||
|
||||
return tempFile;
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new SQLException("Error reading db file inputStream", e);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Float and float.
|
||||
*/
|
||||
public final class ScalarTypeFloat extends ScalarTypeBase<Float> {
|
||||
final class ScalarTypeFloat extends ScalarTypeBase<Float> {
|
||||
|
||||
public ScalarTypeFloat() {
|
||||
ScalarTypeFloat() {
|
||||
super(Float.class, true, Types.REAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Inet to Varchar or Postgres INET.
|
||||
*/
|
||||
public abstract class ScalarTypeInet extends ScalarTypeBaseVarchar<Inet> {
|
||||
abstract class ScalarTypeInet extends ScalarTypeBaseVarchar<Inet> {
|
||||
|
||||
ScalarTypeInet(int jdbcType) {
|
||||
super(Inet.class, false, jdbcType);
|
||||
|
||||
@@ -7,9 +7,9 @@ import java.net.InetAddress;
|
||||
/**
|
||||
* ScalarType for java.net.URI which converts to and from a VARCHAR database column.
|
||||
*/
|
||||
public final class ScalarTypeInetAddress extends ScalarTypeBaseVarchar<InetAddress> {
|
||||
final class ScalarTypeInetAddress extends ScalarTypeBaseVarchar<InetAddress> {
|
||||
|
||||
public ScalarTypeInetAddress() {
|
||||
ScalarTypeInetAddress() {
|
||||
super(InetAddress.class);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for InetAddress to Postgres INET.
|
||||
*/
|
||||
public final class ScalarTypeInetAddressPostgres extends ScalarTypeBaseVarchar<InetAddress> {
|
||||
final class ScalarTypeInetAddressPostgres extends ScalarTypeBaseVarchar<InetAddress> {
|
||||
|
||||
public ScalarTypeInetAddressPostgres() {
|
||||
ScalarTypeInetAddressPostgres() {
|
||||
super(InetAddress.class, false, ExtraDbTypes.INET);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import java.time.Instant;
|
||||
/**
|
||||
* ScalarType for java.sql.Timestamp.
|
||||
*/
|
||||
public final class ScalarTypeInstant extends ScalarTypeBaseDateTime<Instant> {
|
||||
final class ScalarTypeInstant extends ScalarTypeBaseDateTime<Instant> {
|
||||
|
||||
public ScalarTypeInstant(JsonConfig.DateTime mode) {
|
||||
ScalarTypeInstant(JsonConfig.DateTime mode) {
|
||||
super(mode, Instant.class, false, Types.TIMESTAMP);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Integer and int.
|
||||
*/
|
||||
public final class ScalarTypeInteger extends ScalarTypeBase<Integer> {
|
||||
final class ScalarTypeInteger extends ScalarTypeBase<Integer> {
|
||||
|
||||
public static ScalarTypeInteger INSTANCE = new ScalarTypeInteger();
|
||||
|
||||
private ScalarTypeInteger() {
|
||||
ScalarTypeInteger() {
|
||||
super(Integer.class, true, Types.INTEGER);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,12 +11,12 @@ import java.sql.Types;
|
||||
* ScalarType for Joda DateMidnight. This maps to a JDBC Date.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class ScalarTypeJodaDateMidnight extends ScalarTypeBaseDate<org.joda.time.DateMidnight> {
|
||||
final class ScalarTypeJodaDateMidnight extends ScalarTypeBaseDate<org.joda.time.DateMidnight> {
|
||||
|
||||
/**
|
||||
* Instantiates a new scalar type joda date midnight.
|
||||
*/
|
||||
public ScalarTypeJodaDateMidnight(JsonConfig.Date mode) {
|
||||
ScalarTypeJodaDateMidnight(JsonConfig.Date mode) {
|
||||
super(mode, org.joda.time.DateMidnight.class, false, Types.DATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.time.Instant;
|
||||
/**
|
||||
* ScalarType for Joda DateTime. This maps to a JDBC Timestamp.
|
||||
*/
|
||||
public final class ScalarTypeJodaDateTime extends ScalarTypeBaseDateTime<DateTime> {
|
||||
final class ScalarTypeJodaDateTime extends ScalarTypeBaseDateTime<DateTime> {
|
||||
|
||||
public ScalarTypeJodaDateTime(JsonConfig.DateTime mode) {
|
||||
ScalarTypeJodaDateTime(JsonConfig.DateTime mode) {
|
||||
super(mode, DateTime.class, false, Types.TIMESTAMP);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Joda LocalDate. This maps to a JDBC Date.
|
||||
*/
|
||||
public final class ScalarTypeJodaLocalDate extends ScalarTypeBaseDate<LocalDate> {
|
||||
final class ScalarTypeJodaLocalDate extends ScalarTypeBaseDate<LocalDate> {
|
||||
|
||||
public ScalarTypeJodaLocalDate(JsonConfig.Date mode) {
|
||||
ScalarTypeJodaLocalDate(JsonConfig.Date mode) {
|
||||
super(mode, LocalDate.class, false, Types.DATE);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ import java.time.Instant;
|
||||
/**
|
||||
* ScalarType for Joda LocalDateTime. This maps to a JDBC Timestamp.
|
||||
*/
|
||||
public final class ScalarTypeJodaLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime> {
|
||||
final class ScalarTypeJodaLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime> {
|
||||
|
||||
public ScalarTypeJodaLocalDateTime(JsonConfig.DateTime mode) {
|
||||
ScalarTypeJodaLocalDateTime(JsonConfig.DateTime mode) {
|
||||
super(mode, LocalDateTime.class, false, Types.TIMESTAMP);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Joda LocalTime. This maps to a JDBC Time.
|
||||
*/
|
||||
public class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
|
||||
public ScalarTypeJodaLocalTime() {
|
||||
ScalarTypeJodaLocalTime() {
|
||||
super(LocalTime.class, false, Types.TIME);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -13,9 +13,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Joda LocalTime. This maps to a JDBC Time.
|
||||
*/
|
||||
public final class ScalarTypeJodaLocalTimeUTC extends ScalarTypeJodaLocalTime {
|
||||
final class ScalarTypeJodaLocalTimeUTC extends ScalarTypeJodaLocalTime {
|
||||
|
||||
public ScalarTypeJodaLocalTimeUTC() {
|
||||
ScalarTypeJodaLocalTimeUTC() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import org.joda.time.Period;
|
||||
/**
|
||||
* ScalarType for Joda Period stored as DB VARCHAR
|
||||
*/
|
||||
public final class ScalarTypeJodaPeriod extends ScalarTypeBaseVarchar<Period> {
|
||||
final class ScalarTypeJodaPeriod extends ScalarTypeBaseVarchar<Period> {
|
||||
|
||||
public ScalarTypeJodaPeriod() {
|
||||
ScalarTypeJodaPeriod() {
|
||||
super(Period.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,14 @@ import java.sql.Types;
|
||||
/**
|
||||
* Type which maps Jackson's JsonNode to various DB types (Clob, Varchar, Blob) in JSON format.
|
||||
*/
|
||||
public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
|
||||
/**
|
||||
* Clob storage based implementation.
|
||||
*/
|
||||
public static final class Clob extends ScalarTypeJsonNode {
|
||||
static final class Clob extends ScalarTypeJsonNode {
|
||||
|
||||
public Clob(ObjectMapper objectMapper) {
|
||||
Clob(ObjectMapper objectMapper) {
|
||||
super(objectMapper, Types.CLOB);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
/**
|
||||
* Varchar storage based implementation.
|
||||
*/
|
||||
public static final class Varchar extends ScalarTypeJsonNode {
|
||||
static final class Varchar extends ScalarTypeJsonNode {
|
||||
|
||||
public Varchar(ObjectMapper objectMapper) {
|
||||
super(objectMapper, Types.VARCHAR);
|
||||
@@ -56,9 +56,9 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
/**
|
||||
* Blob storage based implementation.
|
||||
*/
|
||||
public static class Blob extends ScalarTypeJsonNode {
|
||||
static class Blob extends ScalarTypeJsonNode {
|
||||
|
||||
public Blob(ObjectMapper objectMapper) {
|
||||
Blob(ObjectMapper objectMapper) {
|
||||
super(objectMapper, Types.BLOB);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
*/
|
||||
final ObjectMapper objectMapper;
|
||||
|
||||
public ScalarTypeJsonNode(ObjectMapper objectMapper, int jdbcType) {
|
||||
ScalarTypeJsonNode(ObjectMapper objectMapper, int jdbcType) {
|
||||
super(JsonNode.class, false, jdbcType);
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
+3
-4
@@ -10,10 +10,9 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* Support for mapping JsonNode to Postgres DB types JSON and JSONB.
|
||||
*/
|
||||
public abstract class ScalarTypeJsonNodePostgres extends ScalarTypeJsonNode {
|
||||
abstract class ScalarTypeJsonNodePostgres extends ScalarTypeJsonNode {
|
||||
|
||||
final ObjectMapper objectMapper;
|
||||
|
||||
final String postgresType;
|
||||
|
||||
ScalarTypeJsonNodePostgres(ObjectMapper objectMapper, int jdbcType, String postgresType) {
|
||||
@@ -31,7 +30,7 @@ public abstract class ScalarTypeJsonNodePostgres extends ScalarTypeJsonNode {
|
||||
/**
|
||||
* ScalarType mapping JsonNode to Postgres JSON database type.
|
||||
*/
|
||||
public static final class JSON extends ScalarTypeJsonNodePostgres {
|
||||
static final class JSON extends ScalarTypeJsonNodePostgres {
|
||||
|
||||
public JSON(ObjectMapper objectMapper) {
|
||||
super(objectMapper, DbPlatformType.JSON, PostgresHelper.JSON_TYPE);
|
||||
@@ -41,7 +40,7 @@ public abstract class ScalarTypeJsonNodePostgres extends ScalarTypeJsonNode {
|
||||
/**
|
||||
* ScalarType mapping JsonNode to Postgres JSONB database type.
|
||||
*/
|
||||
public static final class JSONB extends ScalarTypeJsonNodePostgres {
|
||||
static final class JSONB extends ScalarTypeJsonNodePostgres {
|
||||
|
||||
public JSONB(ObjectMapper objectMapper) {
|
||||
super(objectMapper, DbPlatformType.JSONB, PostgresHelper.JSONB_TYPE);
|
||||
|
||||
@@ -13,9 +13,9 @@ import java.time.ZonedDateTime;
|
||||
/**
|
||||
* ScalarType for java.time.LocalDate. This maps to a JDBC Date.
|
||||
*/
|
||||
public final class ScalarTypeLocalDate extends ScalarTypeBaseDate<LocalDate> {
|
||||
final class ScalarTypeLocalDate extends ScalarTypeBaseDate<LocalDate> {
|
||||
|
||||
public ScalarTypeLocalDate(JsonConfig.Date mode) {
|
||||
ScalarTypeLocalDate(JsonConfig.Date mode) {
|
||||
super(mode, LocalDate.class, false, Types.DATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ import java.time.ZoneId;
|
||||
/**
|
||||
* ScalarType for java.sql.Timestamp.
|
||||
*/
|
||||
public final class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime> {
|
||||
final class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime> {
|
||||
|
||||
public ScalarTypeLocalDateTime(JsonConfig.DateTime mode) {
|
||||
ScalarTypeLocalDateTime(JsonConfig.DateTime mode) {
|
||||
super(mode, LocalDateTime.class, false, Types.TIMESTAMP);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ import java.time.LocalTime;
|
||||
/**
|
||||
* ScalarType for java.time.LocalTime stored as JDBC Time.
|
||||
*/
|
||||
public class ScalarTypeLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
class ScalarTypeLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
|
||||
public ScalarTypeLocalTime() {
|
||||
ScalarTypeLocalTime() {
|
||||
super(LocalTime.class, false, Types.TIME);
|
||||
}
|
||||
|
||||
protected ScalarTypeLocalTime(int jdbcTtype) {
|
||||
ScalarTypeLocalTime(int jdbcTtype) {
|
||||
super(LocalTime.class, false, jdbcTtype);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ import java.time.LocalTime;
|
||||
/**
|
||||
* ScalarType for java.time.LocalTime stored with Nanos as DB BIGINT type.
|
||||
*/
|
||||
public final class ScalarTypeLocalTimeWithNanos extends ScalarTypeLocalTime {
|
||||
final class ScalarTypeLocalTimeWithNanos extends ScalarTypeLocalTime {
|
||||
|
||||
public ScalarTypeLocalTimeWithNanos() {
|
||||
ScalarTypeLocalTimeWithNanos() {
|
||||
super(Types.BIGINT);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.Locale;
|
||||
/**
|
||||
* ScalarType for java.util.Currency which converts to and from a VARCHAR database column.
|
||||
*/
|
||||
public final class ScalarTypeLocale extends ScalarTypeBaseVarchar<Locale> {
|
||||
final class ScalarTypeLocale extends ScalarTypeBaseVarchar<Locale> {
|
||||
|
||||
public ScalarTypeLocale() {
|
||||
ScalarTypeLocale() {
|
||||
super(Locale.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Long and long.
|
||||
*/
|
||||
public final class ScalarTypeLong extends ScalarTypeBase<Long> {
|
||||
final class ScalarTypeLong extends ScalarTypeBase<Long> {
|
||||
|
||||
public ScalarTypeLong() {
|
||||
ScalarTypeLong() {
|
||||
super(Long.class, true, Types.BIGINT);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for String.
|
||||
*/
|
||||
public final class ScalarTypeLongVarchar extends ScalarTypeClob {
|
||||
final class ScalarTypeLongVarchar extends ScalarTypeClob {
|
||||
|
||||
public ScalarTypeLongVarchar() {
|
||||
super(true, Types.LONGVARCHAR);
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for java.math.BigInteger.
|
||||
*/
|
||||
public final class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
|
||||
final class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
|
||||
|
||||
public ScalarTypeMathBigInteger() {
|
||||
ScalarTypeMathBigInteger() {
|
||||
super(BigInteger.class, false, Types.BIGINT);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,9 @@ import java.time.Month;
|
||||
/**
|
||||
* ScalarType mapping for Month enum.
|
||||
*/
|
||||
public final class ScalarTypeMonth extends ScalarTypeEnumWithMapping {
|
||||
final class ScalarTypeMonth extends ScalarTypeEnumWithMapping {
|
||||
|
||||
static final EnumToDbIntegerMap beanDbMap = new EnumToDbIntegerMap();
|
||||
|
||||
static {
|
||||
Month[] values = Month.values();
|
||||
for (Month value : values) {
|
||||
@@ -22,7 +21,7 @@ public final class ScalarTypeMonth extends ScalarTypeEnumWithMapping {
|
||||
}
|
||||
}
|
||||
|
||||
public ScalarTypeMonth() {
|
||||
ScalarTypeMonth() {
|
||||
super(beanDbMap, Month.class, 1);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.tests.unitinternal;
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebeaninternal.server.type.ScalarTypeLocale;
|
||||
import org.junit.Assert;
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
package io.ebean.server.type;
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebean.server.type.MyDayOfWeek;
|
||||
import io.ebean.server.type.MyEnum;
|
||||
import io.ebean.server.type.MySex;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import io.ebeaninternal.server.type.DefaultTypeManager;
|
||||
import io.ebeaninternal.server.type.RsetDataReader;
|
||||
Reference in new issue
Block a user