mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03669dc307 | ||
|
|
2a8fad7364 | ||
|
|
e62db11f01 | ||
|
|
8c8f2b95da | ||
|
|
576eb01187 | ||
|
|
8b18b2a20e | ||
|
|
f5c12a916d | ||
|
|
2f8a99c304 | ||
|
|
cd9a43c3ab | ||
|
|
f251ca5431 | ||
|
|
2c44c80f65 | ||
|
|
d9efeac0a1 | ||
|
|
f4a7d0b6ad | ||
|
|
bc5db1e46a | ||
|
|
8743148238 | ||
|
|
68db6723d0 | ||
|
|
9b1fa43792 | ||
|
|
5f2454831e | ||
|
|
140178bb47 | ||
|
|
f95b4b5c4b | ||
|
|
d3b3a79342 | ||
|
|
52398317bc | ||
|
|
7f2e4f54ff | ||
|
|
9f19ed5376 | ||
|
|
d49a7c415f | ||
|
|
8ffc9ede85 | ||
|
|
eba521563a | ||
|
|
ed71e106df | ||
|
|
050ae49f6b | ||
|
|
d5d9a897ae | ||
|
|
ddf200ffdd | ||
|
|
7fa5e2aa8c | ||
|
|
8bfae9deef | ||
|
|
e6c9f151c1 | ||
|
|
30a0935300 | ||
|
|
b4182d4519 | ||
|
|
93cc0399f1 | ||
|
|
5404dab5a3 | ||
|
|
d70da1d805 | ||
|
|
2225d5b7e8 | ||
|
|
270369bd65 | ||
|
|
a932d61a94 | ||
|
|
24b08663af | ||
|
|
bb6c9c84ba | ||
|
|
a1e185b0f6 | ||
|
|
e2a467ca5a | ||
|
|
4b28933298 | ||
|
|
6077acf134 | ||
|
|
8a4ffd21ab | ||
|
|
d1314124af | ||
|
|
36f018b6aa |
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
custom: https://ebean.io/sponsors
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>11.39.2</version>
|
||||
<version>11.41.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ebean</name>
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-11.39.2</tag>
|
||||
<tag>ebean-11.41.1</tag>
|
||||
</scm>
|
||||
|
||||
<profiles>
|
||||
@@ -117,7 +117,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-annotation</artifactId>
|
||||
<version>4.10</version>
|
||||
<version>4.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -250,7 +250,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-agent</artifactId>
|
||||
<version>11.39.1</version>
|
||||
<version>11.41.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -330,7 +330,7 @@
|
||||
<plugin>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-maven-plugin</artifactId>
|
||||
<version>11.39.1</version>
|
||||
<version>11.41.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
|
||||
@@ -69,8 +69,8 @@ public enum CacheMode {
|
||||
*/
|
||||
GET(true, false);
|
||||
|
||||
private boolean get;
|
||||
private boolean put;
|
||||
private final boolean get;
|
||||
private final boolean put;
|
||||
|
||||
CacheMode(boolean get, boolean put) {
|
||||
this.get = get;
|
||||
|
||||
@@ -80,7 +80,6 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Add a property with ascending order to this OrderBy.
|
||||
*/
|
||||
public Query<T> asc(String propertyName, String collation) {
|
||||
|
||||
list.add(new Property(propertyName, true, collation));
|
||||
return query;
|
||||
}
|
||||
@@ -89,7 +88,6 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Add a property with descending order to this OrderBy.
|
||||
*/
|
||||
public Query<T> desc(String propertyName) {
|
||||
|
||||
list.add(new Property(propertyName, false));
|
||||
return query;
|
||||
}
|
||||
@@ -98,7 +96,6 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Add a property with descending order to this OrderBy.
|
||||
*/
|
||||
public Query<T> desc(String propertyName, String collation) {
|
||||
|
||||
list.add(new Property(propertyName, false, collation));
|
||||
return query;
|
||||
}
|
||||
@@ -108,7 +105,6 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Return true if the property is known to be contained in the order by clause.
|
||||
*/
|
||||
public boolean containsProperty(String propertyName) {
|
||||
|
||||
for (Property aList : list) {
|
||||
if (propertyName.equals(aList.getProperty())) {
|
||||
return true;
|
||||
@@ -161,10 +157,9 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Return a copy of the OrderBy.
|
||||
*/
|
||||
public OrderBy<T> copy() {
|
||||
|
||||
OrderBy<T> copy = new OrderBy<>();
|
||||
for (Property aList : list) {
|
||||
copy.add(aList.copy());
|
||||
for (Property property : list) {
|
||||
copy.add(property.copy());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
@@ -241,6 +236,18 @@ public final class OrderBy<T> implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this order by can be used in select clause.
|
||||
*/
|
||||
public boolean supportsSelect() {
|
||||
for (Property property : list) {
|
||||
if (!property.supportsSelect()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A property and its ascending descending order.
|
||||
*/
|
||||
@@ -401,6 +408,12 @@ public final class OrderBy<T> implements Serializable {
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support use in select clause if no collation or nulls ordering.
|
||||
*/
|
||||
boolean supportsSelect() {
|
||||
return nulls == null && collation == null;
|
||||
}
|
||||
}
|
||||
|
||||
private void parse(String orderByClause) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebean.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Identifies a unique node of an object graph.
|
||||
@@ -85,8 +86,7 @@ public final class ObjectGraphNode implements Serializable {
|
||||
}
|
||||
|
||||
ObjectGraphNode e = (ObjectGraphNode) obj;
|
||||
//noinspection StringEquality
|
||||
return ((e.path == path) || (e.path != null && e.path.equals(path)))
|
||||
return (Objects.equals(e.path, path))
|
||||
&& e.originQueryPoint.equals(originQueryPoint);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public enum ServerCacheType {
|
||||
*/
|
||||
QUERY("_Q");
|
||||
|
||||
private String code;
|
||||
private final String code;
|
||||
|
||||
ServerCacheType(String code) {
|
||||
this.code = code;
|
||||
|
||||
@@ -219,7 +219,6 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
|
||||
/**
|
||||
* Copies all relevant properties for a clone. See {@link #getShallowCopy()}
|
||||
* @param other
|
||||
*/
|
||||
protected void setFromOriginal(AbstractBeanCollection<E> other) {
|
||||
this.disableLazyLoad = other.disableLazyLoad;
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public Set<Entry<K, E>> entrySet() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
|
||||
@@ -77,6 +77,9 @@ public class PlatformConfig {
|
||||
this.geometrySRID = platformConfig.geometrySRID;
|
||||
this.dbUuid = platformConfig.dbUuid;
|
||||
this.caseSensitiveCollation = platformConfig.caseSensitiveCollation;
|
||||
this.allQuotedIdentifiers = platformConfig.allQuotedIdentifiers;
|
||||
this.databaseInetAddressVarchar = platformConfig.databaseInetAddressVarchar;
|
||||
this.customDbTypeMappings = platformConfig.customDbTypeMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -653,6 +653,7 @@ public class ServerConfig {
|
||||
* @param cls The type of the service object to obtain
|
||||
* @return The service object given the class type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <P> P getServiceObject(Class<P> cls) {
|
||||
return (P) serviceObject.get(serviceObjectKey(cls));
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public enum TenantMode {
|
||||
* (that holds configuration e.g.)
|
||||
*/
|
||||
DB_WITH_MASTER(true, true);
|
||||
|
||||
boolean dynamicDataSource;
|
||||
boolean ddlEnabled;
|
||||
|
||||
final boolean dynamicDataSource;
|
||||
final boolean ddlEnabled;
|
||||
|
||||
TenantMode(boolean dynamicDataSource, boolean ddlEnabled) {
|
||||
this.dynamicDataSource = dynamicDataSource;
|
||||
@@ -50,12 +50,12 @@ public enum TenantMode {
|
||||
public boolean isDynamicDataSource() {
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true, if DDL is enabled.
|
||||
*/
|
||||
public boolean isDdlEnabled() {
|
||||
return ddlEnabled;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,15 +27,13 @@ public class DbDefaultValue {
|
||||
* The key for the NOW / current timestamp.
|
||||
*/
|
||||
public static final String NOW = "now";
|
||||
|
||||
|
||||
/**
|
||||
* The 'null' literal.
|
||||
*/
|
||||
public static final String NULL = "null";
|
||||
|
||||
|
||||
|
||||
protected Map<String, String> map = new LinkedHashMap<>();
|
||||
protected final Map<String, String> map = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Set the DB now function.
|
||||
@@ -82,10 +80,9 @@ public class DbDefaultValue {
|
||||
return val != null ? val : dbDefaultLiteral;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method checks & convert the {@link DbDefault#value()} to a valid SQL literal.
|
||||
*
|
||||
*
|
||||
* This is mainly to quote string literals and verify integer/dates for correctness.
|
||||
* <p>
|
||||
* Note: There are some special cases:
|
||||
@@ -98,24 +95,24 @@ public class DbDefaultValue {
|
||||
* If you need really the String "null", you have to specify <code>@DbDefault("'null'")</code>
|
||||
* which gives you the <code>default 'null'</code> statement.</li>
|
||||
* <li>Any statement, that begins and ends with single quote will not be checked or get quoted again.</li>
|
||||
* <li>A statement that begins with "$RAW:", e.g <code>@DbDefault("$RAW:N'SANDNES'")</code> will lead to
|
||||
* <li>A statement that begins with "$RAW:", e.g <code>@DbDefault("$RAW:N'SANDNES'")</code> will lead to
|
||||
* a <code>default N'SANDNES'</code> in DDL. Note that this is platform specific!</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static String toSqlLiteral(String defaultValue, Class<?> propertyType, int sqlType) {
|
||||
if (propertyType == null
|
||||
|| defaultValue == null
|
||||
|| defaultValue == null
|
||||
|| NULL.equals(defaultValue)
|
||||
|| (defaultValue.startsWith("'") && defaultValue.endsWith("'"))
|
||||
|| (defaultValue.startsWith("$RAW:"))) {
|
||||
|| (defaultValue.startsWith("$RAW:"))) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
if (Boolean.class.isAssignableFrom(propertyType) || Boolean.TYPE.isAssignableFrom(propertyType)) {
|
||||
return toBooleanLiteral(defaultValue);
|
||||
}
|
||||
|
||||
if (Number.class.isAssignableFrom(propertyType)
|
||||
|
||||
if (Number.class.isAssignableFrom(propertyType)
|
||||
|| Byte.TYPE.equals(propertyType)
|
||||
|| Short.TYPE.equals(propertyType)
|
||||
|| Integer.TYPE.equals(propertyType)
|
||||
@@ -126,7 +123,7 @@ public class DbDefaultValue {
|
||||
Double.valueOf(defaultValue); // verify if it is a number
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
// check if it is a date/time - in all other cases return quoted defaultValue
|
||||
switch (sqlType) {
|
||||
// date
|
||||
@@ -155,7 +152,7 @@ public class DbDefaultValue {
|
||||
}
|
||||
throw new IllegalArgumentException("'" + value + "' is not a valid value for boolean");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This adds single qoutes around the <code>value</code> and doubles single quotes.
|
||||
* "User's home" will return "'User''s home'"
|
||||
@@ -175,7 +172,7 @@ public class DbDefaultValue {
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static String toDateLiteral(String value) {
|
||||
if (NOW.equals(value)) {
|
||||
return value; // this will get translated later
|
||||
@@ -191,7 +188,7 @@ public class DbDefaultValue {
|
||||
DatatypeConverter.parseTime(value); // verify
|
||||
return toTextLiteral(value);
|
||||
}
|
||||
|
||||
|
||||
private static String toDateTimeLiteral(String value) {
|
||||
if (NOW.equals(value)) {
|
||||
return value; // this will get translated later
|
||||
|
||||
@@ -11,12 +11,12 @@ class DbPlatformTypeLookup {
|
||||
/**
|
||||
* A map to lookup the type by name.
|
||||
*/
|
||||
private Map<String, DbType> nameLookup = new HashMap<>();
|
||||
private final Map<String, DbType> nameLookup = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A map to lookup the type by JDBC int value.
|
||||
*/
|
||||
private Map<Integer, DbType> idLookup = new HashMap<>();
|
||||
private final Map<Integer, DbType> idLookup = new HashMap<>();
|
||||
|
||||
DbPlatformTypeLookup() {
|
||||
addAll();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DbPlatformTypeMapping {
|
||||
}
|
||||
}
|
||||
|
||||
private static DbPlatformTypeLookup lookup = new DbPlatformTypeLookup();
|
||||
private static final DbPlatformTypeLookup lookup = new DbPlatformTypeLookup();
|
||||
|
||||
private static final DbPlatformType BOOLEAN_LOGICAL = new BooleanLogicalType();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class SqlErrorCodes {
|
||||
|
||||
private Map<String,DataErrorType> map = new HashMap<>();
|
||||
private final Map<String,DataErrorType> map = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Map the codes to AcquireLockException.
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class QueryPlanRequest {
|
||||
|
||||
private List<MetaQueryPlan> plans = new ArrayList<>();
|
||||
private final List<MetaQueryPlan> plans = new ArrayList<>();
|
||||
|
||||
private Connection connection;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.ServiceLoader;
|
||||
*/
|
||||
class MetricServiceProvider {
|
||||
|
||||
private static MetricFactory metricFactory = init();
|
||||
private static final MetricFactory metricFactory = init();
|
||||
|
||||
private static MetricFactory init() {
|
||||
|
||||
|
||||
@@ -223,7 +223,6 @@ public interface BeanType<T> {
|
||||
|
||||
/**
|
||||
* Visit all children recursively
|
||||
* @param visitor
|
||||
*/
|
||||
void visitAllInheritanceChildren(Consumer<BeanType<?>> visitor);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public interface ExpressionPath {
|
||||
/**
|
||||
* Return the underlying bean property.
|
||||
*/
|
||||
public Property getProperty();
|
||||
Property getProperty();
|
||||
|
||||
/**
|
||||
* The ElPrefix plus name.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.ebean.plugin;
|
||||
|
||||
import io.ebean.bean.EntityBean;
|
||||
|
||||
/**
|
||||
* Property of a entity bean that is a ToMany property.
|
||||
*/
|
||||
public interface PropertyAssocMany extends Property {
|
||||
|
||||
/**
|
||||
* Add the loaded current bean to its associated parent.
|
||||
* <p>
|
||||
* Helper method used by Ebean Elastic integration when loading with a persistence context.
|
||||
*/
|
||||
void lazyLoadMany(EntityBean current);
|
||||
}
|
||||
@@ -49,13 +49,12 @@ class PathPropertiesParser {
|
||||
private String getPath() {
|
||||
do {
|
||||
char c1 = chars[pos++];
|
||||
switch (c1) {
|
||||
case '(':
|
||||
return currentWord();
|
||||
default:
|
||||
if (pos == 1) {
|
||||
return "";
|
||||
}
|
||||
if (c1 == '(') {
|
||||
return currentWord();
|
||||
} else {
|
||||
if (pos == 1) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
} while (pos < eof);
|
||||
throw new RuntimeException("Hit EOF while reading sectionTitle from " + startPos);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -107,9 +108,7 @@ public class AnnotationUtil {
|
||||
* Finds all annotations recusively for a class and its superclasses or interfaces.
|
||||
*/
|
||||
public static <A extends Annotation> Set<A> findAnnotationsRecursive(Class<?> clazz, Class<A> annotationType) {
|
||||
if (annotationType == null) {
|
||||
return null;
|
||||
}
|
||||
Objects.requireNonNull(annotationType);
|
||||
Set<A> ret = new LinkedHashSet<>();
|
||||
Set<Annotation> visited = new HashSet<>();
|
||||
Set<Class<?>> visitedInterfaces = new HashSet<>();
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
*/
|
||||
public class BeanCacheResult<T> {
|
||||
|
||||
private List<Entry<T>> list = new ArrayList<>();
|
||||
private final List<Entry<T>> list = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Add an entry.
|
||||
|
||||
@@ -115,10 +115,10 @@ public class BindParams implements Serializable {
|
||||
* Return a Natural Key bind param if supported.
|
||||
*/
|
||||
public NaturalKeyBindParam getNaturalKeyBindParam() {
|
||||
if (positionedParameters != null) {
|
||||
if (!positionedParameters.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (namedParameters != null && namedParameters.size() == 1) {
|
||||
if (namedParameters.size() == 1) {
|
||||
Entry<String, Param> e = namedParameters.entrySet().iterator().next();
|
||||
return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue());
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class NaturalKeyEntry {
|
||||
|
||||
private Map<String,Object> map = new HashMap<>();
|
||||
private Object key;
|
||||
private final Map<String,Object> map = new HashMap<>();
|
||||
private final Object key;
|
||||
private Object inValue;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ScopedTransaction extends SpiTransactionProxy {
|
||||
/**
|
||||
* Stack of 'nested' transactions.
|
||||
*/
|
||||
private ArrayStack<ScopeTrans> stack = new ArrayStack<>();
|
||||
private final ArrayStack<ScopeTrans> stack = new ArrayStack<>();
|
||||
|
||||
private ScopeTrans current;
|
||||
|
||||
|
||||
@@ -106,9 +106,9 @@ public interface SpiQuery<T> extends Query<T>, TxnProfileEventCodes {
|
||||
*/
|
||||
UPDATE(FIND_UPDATE, "update", true);
|
||||
|
||||
private boolean update;
|
||||
private String profileEventId;
|
||||
private String label;
|
||||
private final boolean update;
|
||||
private final String profileEventId;
|
||||
private final String label;
|
||||
|
||||
Type(String profileEventId, String label) {
|
||||
this(profileEventId, label, false);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TransactionEvent implements Serializable {
|
||||
* Return the list of PersistRequestBean's for this transaction.
|
||||
*/
|
||||
public List<PersistRequestBean<?>> getListenerNotify() {
|
||||
return (listenerNotify == null) ? null : listenerNotify;
|
||||
return listenerNotify;
|
||||
}
|
||||
|
||||
public TransactionEventTable getEventTables() {
|
||||
|
||||
@@ -60,10 +60,7 @@ class LastMigration {
|
||||
}
|
||||
|
||||
private static boolean includeSqlFile(String lowerFileName) {
|
||||
if (lowerFileName.startsWith("r") || lowerFileName.startsWith("i") || !lowerFileName.endsWith(SQL)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !lowerFileName.startsWith("r") && !lowerFileName.startsWith("i") && lowerFileName.endsWith(SQL);
|
||||
}
|
||||
|
||||
private static boolean includeModelFile(String lowerFileName) {
|
||||
|
||||
@@ -62,14 +62,14 @@ public class BaseTableDdl implements TableDdl {
|
||||
* Used to check that indexes on foreign keys should be skipped as a unique index on the columns
|
||||
* already exists.
|
||||
*/
|
||||
protected IndexSet indexSet = new IndexSet();
|
||||
protected final IndexSet indexSet = new IndexSet();
|
||||
|
||||
/**
|
||||
* Used when unique constraints specifically for OneToOne can't be created normally (MsSqlServer).
|
||||
*/
|
||||
protected List<Column> externalUnique = new ArrayList<>();
|
||||
protected final List<Column> externalUnique = new ArrayList<>();
|
||||
|
||||
protected List<UniqueConstraint> externalCompoundUnique = new ArrayList<>();
|
||||
protected final List<UniqueConstraint> externalCompoundUnique = new ArrayList<>();
|
||||
|
||||
// counters used when constraint names are truncated due to maximum length
|
||||
// and these counters are used to keep the constraint name unique
|
||||
@@ -82,9 +82,9 @@ public class BaseTableDdl implements TableDdl {
|
||||
* Base tables that have associated history tables that need their triggers/functions regenerated as
|
||||
* columns have been added, removed, included or excluded.
|
||||
*/
|
||||
protected Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<>();
|
||||
protected final Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<>();
|
||||
|
||||
private boolean strictMode;
|
||||
private final boolean strictMode;
|
||||
|
||||
private final HistorySupport historySupport;
|
||||
|
||||
@@ -134,7 +134,7 @@ public class BaseTableDdl implements TableDdl {
|
||||
if (defaultValue == null) {
|
||||
handleStrictError(tableName, columnName);
|
||||
}
|
||||
before = Arrays.asList(platformDdl.getUpdateNullWithDefault());
|
||||
before = Collections.singletonList(platformDdl.getUpdateNullWithDefault());
|
||||
} else {
|
||||
before = getScriptsForPlatform(alter.getBefore(), platformDdl.getPlatform().getName());
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class CurrentModel {
|
||||
List<DdlScript> ddlScript = extraDdl.getDdlScript();
|
||||
for (DdlScript script : ddlScript) {
|
||||
if (script.isInit() && ExtraDdlXmlReader.matchPlatform(server.getDatabasePlatform().getName(), script.getPlatforms())) {
|
||||
ddl.append(prefix + script.getName()).append('\n');
|
||||
ddl.append(prefix).append(script.getName()).append('\n');
|
||||
ddl.append(script.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.ebeaninternal.dbmigration.migration.DdlScript;
|
||||
import io.ebeaninternal.server.deploy.DbMigrationInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A column in the logical model.
|
||||
@@ -309,7 +310,7 @@ public class MColumn {
|
||||
}
|
||||
|
||||
protected static boolean different(String val1, String val2) {
|
||||
return (val1 == null) ? val2 != null : !val1.equals(val2);
|
||||
return !Objects.equals(val1, val2);
|
||||
}
|
||||
|
||||
private boolean hasValue(String val) {
|
||||
|
||||
@@ -769,7 +769,7 @@ public class MTable {
|
||||
nullableColumns.add(columnName);
|
||||
}
|
||||
}
|
||||
uniq.setNullableColumns(nullableColumns.toArray(new String[nullableColumns.size()]));
|
||||
uniq.setNullableColumns(nullableColumns.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -49,8 +49,7 @@ class ModelBuildIntersectionTable {
|
||||
|
||||
private void buildFkConstraints() {
|
||||
|
||||
PropertyForeignKey foreignKey = manyProp.getForeignKey();
|
||||
if (foreignKey == null || !foreignKey.isNoConstraint()) {
|
||||
if (manyProp.hasForeignKeyConstraint()) {
|
||||
ctx.fkeyBuilder(intersectionTable)
|
||||
.addForeignKey(manyProp.getBeanDescriptor(), intersectionTableJoin, true)
|
||||
.addForeignKey(manyProp.getTargetDescriptor(), tableJoin, false);
|
||||
|
||||
+11
-6
@@ -170,8 +170,6 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
|
||||
List<MColumn> modelColumns = new ArrayList<>(columns.length);
|
||||
|
||||
PropertyForeignKey foreignKey = p.getForeignKey();
|
||||
|
||||
MCompoundForeignKey compoundKey = null;
|
||||
if (columns.length > 1) {
|
||||
// compound foreign key
|
||||
@@ -196,7 +194,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
col.setDbMigrationInfos(p.getDbMigrationInfos());
|
||||
col.setDefaultValue(p.getDbColumnDefault());
|
||||
if (columns.length == 1) {
|
||||
if (p.hasForeignKey() && !importedProperty.getBeanDescriptor().suppressForeignKey()) {
|
||||
if (p.hasForeignKeyConstraint() && !importedProperty.getBeanDescriptor().suppressForeignKey()) {
|
||||
// single references column (put it on the column)
|
||||
String refTable = importedProperty.getBeanDescriptor().getBaseTable();
|
||||
if (refTable == null) {
|
||||
@@ -208,6 +206,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
if (p.hasForeignKeyIndex()) {
|
||||
col.setForeignKeyIndex(determineForeignKeyIndexName(col.getName()));
|
||||
}
|
||||
PropertyForeignKey foreignKey = p.getForeignKey();
|
||||
if (foreignKey != null) {
|
||||
col.setForeignKeyModes(foreignKey.getOnDelete(), foreignKey.getOnUpdate());
|
||||
}
|
||||
@@ -256,9 +255,15 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
}
|
||||
TableJoin primaryKeyJoin = p.getBeanDescriptor().getPrimaryKeyJoin();
|
||||
if (primaryKeyJoin != null && !table.isPartitioned()) {
|
||||
TableJoinColumn[] columns = primaryKeyJoin.columns();
|
||||
col.setReferences(primaryKeyJoin.getTable() + "." + columns[0].getForeignDbColumn());
|
||||
col.setForeignKeyName(determineForeignKeyConstraintName(col.getName()));
|
||||
final PropertyForeignKey foreignKey = primaryKeyJoin.getForeignKey();
|
||||
if (foreignKey == null || !foreignKey.isNoConstraint()) {
|
||||
TableJoinColumn[] columns = primaryKeyJoin.columns();
|
||||
col.setReferences(primaryKeyJoin.getTable() + "." + columns[0].getForeignDbColumn());
|
||||
col.setForeignKeyName(determineForeignKeyConstraintName(col.getName()));
|
||||
if (foreignKey != null) {
|
||||
col.setForeignKeyModes(foreignKey.getOnDelete(), foreignKey.getOnUpdate());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
col.setDefaultValue(p.getDbColumnDefault());
|
||||
|
||||
@@ -181,7 +181,7 @@ public class DJsonService implements SpiJsonService {
|
||||
if (modifyAware) {
|
||||
return ((ModifyAwareList<T>) list).asSet();
|
||||
} else {
|
||||
return new LinkedHashSet<T>(list);
|
||||
return new LinkedHashSet<>(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
*/
|
||||
public class AutoTuneCollection {
|
||||
|
||||
List<Entry> entries = new ArrayList<>();
|
||||
final List<Entry> entries = new ArrayList<>();
|
||||
|
||||
public Entry add(ObjectGraphOrigin origin, OrmQueryDetail detail, String sourceQuery) {
|
||||
Entry entry = new Entry(origin, detail, sourceQuery);
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.SpiSqlBinding;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.lib.util.Str;
|
||||
import io.ebeaninternal.server.lib.Str;
|
||||
import io.ebeaninternal.server.persist.Binder;
|
||||
import io.ebeaninternal.server.persist.TrimLogSql;
|
||||
import io.ebeaninternal.server.util.BindParamsParser;
|
||||
|
||||
@@ -91,17 +91,13 @@ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||
if (map == null) {
|
||||
return schedulePool.schedule(c, delay, unit);
|
||||
} else {
|
||||
return schedulePool.schedule(new Callable<V>() {
|
||||
@Override
|
||||
public V call() throws Exception {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
return c.call();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
return schedulePool.schedule(() -> {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
return c.call();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
|
||||
}, delay, unit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,7 @@ public class DefaultCallStackFactory implements CallStackFactory {
|
||||
if (element.getClassName().startsWith(IO_EBEAN)) {
|
||||
return true;
|
||||
}
|
||||
if (element.getMethodName().startsWith("_ebean_")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return element.getMethodName().startsWith("_ebean_");
|
||||
}
|
||||
|
||||
private CallStack createCallStack(StackTraceElement[] finalTrace) {
|
||||
|
||||
@@ -102,7 +102,7 @@ import io.ebeaninternal.server.query.LimitOffsetPagedList;
|
||||
import io.ebeaninternal.server.query.QueryFutureIds;
|
||||
import io.ebeaninternal.server.query.QueryFutureList;
|
||||
import io.ebeaninternal.server.query.QueryFutureRowCount;
|
||||
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.query.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.querydefn.DefaultDtoQuery;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmUpdate;
|
||||
@@ -160,7 +160,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
/**
|
||||
* Clock to use for WhenModified and WhenCreated.
|
||||
*/
|
||||
private ClockService clockService;
|
||||
private final ClockService clockService;
|
||||
|
||||
private final CallStackFactory callStackFactory;
|
||||
|
||||
@@ -658,7 +658,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T createEntityBean(Class<T> type) {
|
||||
return getBeanDescriptor(type).createBean();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.dto.DtoColumn;
|
||||
import io.ebeaninternal.server.dto.DtoMappingRequest;
|
||||
import io.ebeaninternal.server.dto.DtoQueryPlan;
|
||||
import io.ebeaninternal.server.persist.Binder;
|
||||
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.query.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.type.DataReader;
|
||||
import io.ebeaninternal.server.type.RsetDataReader;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ import io.ebeaninternal.server.persist.platform.PostgresMultiValueBind;
|
||||
import io.ebeaninternal.server.query.CQueryEngine;
|
||||
import io.ebeaninternal.server.query.DefaultOrmQueryEngine;
|
||||
import io.ebeaninternal.server.query.DefaultRelationalQueryEngine;
|
||||
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.query.DtoQueryEngine;
|
||||
import io.ebeaninternal.server.readaudit.DefaultReadAuditLogger;
|
||||
import io.ebeaninternal.server.readaudit.DefaultReadAuditPrepare;
|
||||
import io.ebeaninternal.server.text.json.DJsonContext;
|
||||
@@ -163,7 +163,7 @@ public class InternalConfiguration {
|
||||
|
||||
private final SpiLogManager logManager;
|
||||
|
||||
public InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor,
|
||||
InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor,
|
||||
ServerConfig serverConfig, BootupClasses bootupClasses) {
|
||||
|
||||
this.online = online;
|
||||
@@ -237,7 +237,7 @@ public class InternalConfiguration {
|
||||
return docStoreFactory;
|
||||
}
|
||||
|
||||
public ClockService getClockService() {
|
||||
ClockService getClockService() {
|
||||
return clockService;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ public class InternalConfiguration {
|
||||
/**
|
||||
* Return the ReadAuditLogger implementation to use.
|
||||
*/
|
||||
public ReadAuditLogger getReadAuditLogger() {
|
||||
ReadAuditLogger getReadAuditLogger() {
|
||||
ReadAuditLogger found = bootupClasses.getReadAuditLogger();
|
||||
return plugin(found != null ? found : new DefaultReadAuditLogger());
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public class InternalConfiguration {
|
||||
/**
|
||||
* Return the ReadAuditPrepare implementation to use.
|
||||
*/
|
||||
public ReadAuditPrepare getReadAuditPrepare() {
|
||||
ReadAuditPrepare getReadAuditPrepare() {
|
||||
ReadAuditPrepare found = bootupClasses.getReadAuditPrepare();
|
||||
return plugin(found != null ? found : new DefaultReadAuditPrepare());
|
||||
}
|
||||
@@ -328,35 +328,33 @@ public class InternalConfiguration {
|
||||
|
||||
private MultiValueBind createMultiValueBind(Platform platform) {
|
||||
// only Postgres at this stage
|
||||
switch (platform) {
|
||||
case POSTGRES:
|
||||
return new PostgresMultiValueBind();
|
||||
default:
|
||||
return new MultiValueBind();
|
||||
if (platform == Platform.POSTGRES) {
|
||||
return new PostgresMultiValueBind();
|
||||
}
|
||||
return new MultiValueBind();
|
||||
}
|
||||
|
||||
public SpiJsonContext createJsonContext(SpiEbeanServer server) {
|
||||
SpiJsonContext createJsonContext(SpiEbeanServer server) {
|
||||
return new DJsonContext(server, jsonFactory, typeManager);
|
||||
}
|
||||
|
||||
public AutoTuneService createAutoTuneService(SpiEbeanServer server) {
|
||||
AutoTuneService createAutoTuneService(SpiEbeanServer server) {
|
||||
return AutoTuneServiceFactory.create(server, serverConfig);
|
||||
}
|
||||
|
||||
public DtoQueryEngine createDtoQueryEngine() {
|
||||
DtoQueryEngine createDtoQueryEngine() {
|
||||
return new DtoQueryEngine(binder);
|
||||
}
|
||||
|
||||
public RelationalQueryEngine createRelationalQueryEngine() {
|
||||
RelationalQueryEngine createRelationalQueryEngine() {
|
||||
return new DefaultRelationalQueryEngine(binder, serverConfig.getDatabaseBooleanTrue(), serverConfig.getPlatformConfig().getDbUuid().useBinaryOptimized());
|
||||
}
|
||||
|
||||
public OrmQueryEngine createOrmQueryEngine() {
|
||||
OrmQueryEngine createOrmQueryEngine() {
|
||||
return new DefaultOrmQueryEngine(cQueryEngine, binder);
|
||||
}
|
||||
|
||||
public Persister createPersister(SpiEbeanServer server) {
|
||||
Persister createPersister(SpiEbeanServer server) {
|
||||
return new DefaultPersister(server, binder, beanDescriptorManager);
|
||||
}
|
||||
|
||||
@@ -384,7 +382,7 @@ public class InternalConfiguration {
|
||||
return binder;
|
||||
}
|
||||
|
||||
public BeanDescriptorManager getBeanDescriptorManager() {
|
||||
BeanDescriptorManager getBeanDescriptorManager() {
|
||||
return beanDescriptorManager;
|
||||
}
|
||||
|
||||
@@ -400,7 +398,7 @@ public class InternalConfiguration {
|
||||
return deployUtil;
|
||||
}
|
||||
|
||||
public CQueryEngine getCQueryEngine() {
|
||||
CQueryEngine getCQueryEngine() {
|
||||
return cQueryEngine;
|
||||
}
|
||||
|
||||
@@ -416,14 +414,14 @@ public class InternalConfiguration {
|
||||
/**
|
||||
* Create the DocStoreIntegration components for the given server.
|
||||
*/
|
||||
public DocStoreIntegration createDocStoreIntegration(SpiServer server) {
|
||||
DocStoreIntegration createDocStoreIntegration(SpiServer server) {
|
||||
return plugin(docStoreFactory.create(server));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TransactionManager taking into account autoCommit mode.
|
||||
*/
|
||||
public TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) {
|
||||
TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) {
|
||||
|
||||
TransactionScopeManager scopeManager = createTransactionScopeManager();
|
||||
boolean notifyL2CacheInForeground = cacheManager.isLocalL2Caching() || serverConfig.isNotifyL2CacheInForeground();
|
||||
@@ -498,9 +496,9 @@ public class InternalConfiguration {
|
||||
}
|
||||
if (externalTransactionManager != null) {
|
||||
logger.info("Using Transaction Manager [" + externalTransactionManager.getClass() + "]");
|
||||
return new ExternalTransactionScopeManager(serverConfig.getName(), externalTransactionManager);
|
||||
return new ExternalTransactionScopeManager(externalTransactionManager);
|
||||
} else {
|
||||
return new DefaultTransactionScopeManager(serverConfig.getName());
|
||||
return new DefaultTransactionScopeManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,11 +559,11 @@ public class InternalConfiguration {
|
||||
return multiValueBind;
|
||||
}
|
||||
|
||||
public DtoBeanManager getDtoBeanManager() {
|
||||
DtoBeanManager getDtoBeanManager() {
|
||||
return dtoBeanManager;
|
||||
}
|
||||
|
||||
public SpiLogManager getLogManager() {
|
||||
SpiLogManager getLogManager() {
|
||||
return logManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
||||
DELETE_PERMANENT(EVT_DELETE_PERMANENT),
|
||||
UPDATESQL(EVT_UPDATESQL),
|
||||
CALLABLESQL(EVT_CALLABLESQL);
|
||||
String profileEventId;
|
||||
final String profileEventId;
|
||||
|
||||
Type(String profileEventId) {
|
||||
this.profileEventId = profileEventId;
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
private DocStoreMode docStoreMode;
|
||||
|
||||
private ConcurrencyMode concurrencyMode;
|
||||
private final ConcurrencyMode concurrencyMode;
|
||||
|
||||
/**
|
||||
* The unique id used for logging summary.
|
||||
@@ -1326,10 +1326,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
*/
|
||||
public void docStorePersist() {
|
||||
idValue = beanDescriptor.getId(entityBean);
|
||||
switch (type) {
|
||||
case UPDATE:
|
||||
dirtyProperties = intercept.getDirtyProperties();
|
||||
break;
|
||||
if (type == Type.UPDATE) {
|
||||
dirtyProperties = intercept.getDirtyProperties();
|
||||
}
|
||||
// processing now so set IGNORE (unlike DB + DocStore processing with post-commit)
|
||||
docStoreMode = DocStoreMode.IGNORE;
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.core;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiSqlUpdate;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.lib.util.Str;
|
||||
import io.ebeaninternal.server.lib.Str;
|
||||
import io.ebeaninternal.server.persist.BatchControl;
|
||||
import io.ebeaninternal.server.persist.PersistExecute;
|
||||
import io.ebeaninternal.server.persist.TrimLogSql;
|
||||
@@ -29,7 +29,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
|
||||
private boolean addBatch;
|
||||
|
||||
private boolean forceNoBatch;
|
||||
private final boolean forceNoBatch;
|
||||
|
||||
private boolean batchThisRequest;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
|
||||
for (int i = 1; i < columnsPlusOne; i++) {
|
||||
propNames.add(metaData.getColumnLabel(i));
|
||||
}
|
||||
return propNames.toArray(new String[propNames.size()]);
|
||||
return propNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,9 +13,9 @@ import java.sql.SQLException;
|
||||
*/
|
||||
abstract class AssocOneHelp {
|
||||
|
||||
protected final BeanPropertyAssocOne<?> property;
|
||||
final BeanPropertyAssocOne<?> property;
|
||||
|
||||
protected final BeanDescriptor<?> target;
|
||||
private final BeanDescriptor<?> target;
|
||||
|
||||
private final String path;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
@Override
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
|
||||
if (!subQuery) {
|
||||
if (!subQuery && inherit.hasChildren()) {
|
||||
// add discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
||||
String tableAlias = ctx.getTableAlias(relativePrefix);
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
|
||||
|
||||
final BeanPropertyAssocMany<T> many;
|
||||
final BeanDescriptor<T> targetDescriptor;
|
||||
private final BeanDescriptor<T> targetDescriptor;
|
||||
final String propertyName;
|
||||
|
||||
BeanCollectionLoader loader;
|
||||
|
||||
@@ -36,8 +36,6 @@ public class BeanCascadeInfo {
|
||||
refresh = true;
|
||||
break;
|
||||
case PERSIST:
|
||||
save = true;
|
||||
break;
|
||||
case MERGE:
|
||||
save = true;
|
||||
break;
|
||||
|
||||
@@ -92,6 +92,7 @@ import io.ebeanservice.docstore.api.mapping.DocumentMapping;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -142,11 +143,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
ORM, EMBEDDED, VIEW, SQL, DOC
|
||||
}
|
||||
|
||||
/**
|
||||
* The EbeanServer name. Same as the plugin name.
|
||||
*/
|
||||
private final String serverName;
|
||||
|
||||
/**
|
||||
* The nature/type of this bean.
|
||||
*/
|
||||
@@ -235,7 +231,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Map of BeanProperty Linked so as to preserve order.
|
||||
*/
|
||||
protected final LinkedHashMap<String, BeanProperty> propMap;
|
||||
private final LinkedHashMap<String, BeanProperty> propMap;
|
||||
|
||||
/**
|
||||
* Map of DB column to property path (for nativeSql mapping).
|
||||
@@ -252,7 +248,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
*/
|
||||
final Class<T> beanType;
|
||||
|
||||
protected final Class<?> rootBeanType;
|
||||
final Class<?> rootBeanType;
|
||||
|
||||
/**
|
||||
* This is not sent to a remote client.
|
||||
@@ -287,22 +283,17 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
*/
|
||||
private final ChangeLogFilter changeLogFilter;
|
||||
|
||||
/**
|
||||
* The table joins for this bean.
|
||||
*/
|
||||
private final TableJoin[] derivedTableJoins;
|
||||
|
||||
/**
|
||||
* Inheritance information. Server side only.
|
||||
*/
|
||||
protected final InheritInfo inheritInfo;
|
||||
final InheritInfo inheritInfo;
|
||||
|
||||
private final boolean abstractType;
|
||||
|
||||
/**
|
||||
* Derived list of properties that make up the unique id.
|
||||
*/
|
||||
protected final BeanProperty idProperty;
|
||||
private final BeanProperty idProperty;
|
||||
|
||||
private final int idPropertyIndex;
|
||||
|
||||
@@ -374,7 +365,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* All non transient properties excluding the id properties.
|
||||
*/
|
||||
private final BeanProperty[] propertiesNonTransient;
|
||||
protected final BeanProperty[] propertiesIndex;
|
||||
final BeanProperty[] propertiesIndex;
|
||||
private final BeanProperty[] propertiesGenInsert;
|
||||
private final BeanProperty[] propertiesGenUpdate;
|
||||
private final List<BeanProperty[]> propertiesUnique = new ArrayList<>();
|
||||
@@ -423,7 +414,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
|
||||
private final BeanDescriptorDraftHelp<T> draftHelp;
|
||||
private final BeanDescriptorCacheHelp<T> cacheHelp;
|
||||
final BeanDescriptorJsonHelp<T> jsonHelp;
|
||||
private final BeanDescriptorJsonHelp<T> jsonHelp;
|
||||
private DocStoreBeanAdapter<T> docStoreAdapter;
|
||||
private DocumentMapping docMapping;
|
||||
private boolean docStoreEmbeddedInvalidation;
|
||||
@@ -439,7 +430,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
|
||||
this.owner = owner;
|
||||
this.multiValueSupported = owner.isMultiValueSupported();
|
||||
this.serverName = owner.getServerName();
|
||||
this.entityType = deploy.getEntityType();
|
||||
this.properties = deploy.getProperties();
|
||||
this.name = InternString.intern(deploy.getName());
|
||||
@@ -529,8 +519,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
this.propertiesGenInsert = listHelper.getGeneratedInsert();
|
||||
this.propertiesGenUpdate = listHelper.getGeneratedUpdate();
|
||||
|
||||
this.derivedTableJoins = listHelper.getTableJoin();
|
||||
|
||||
boolean noRelationships = propertiesOne.length + propertiesMany.length == 0;
|
||||
|
||||
this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly();
|
||||
@@ -616,7 +604,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Create an entity bean that is used as a prototype/factory to create new instances.
|
||||
*/
|
||||
protected EntityBean createPrototypeEntityBean(Class<T> beanType) {
|
||||
EntityBean createPrototypeEntityBean(Class<T> beanType) {
|
||||
if (Modifier.isAbstract(beanType.getModifiers())) {
|
||||
return null;
|
||||
}
|
||||
@@ -655,7 +643,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Return true if this is an abstract type.
|
||||
*/
|
||||
public boolean isAbstractType() {
|
||||
boolean isAbstractType() {
|
||||
return abstractType;
|
||||
}
|
||||
|
||||
@@ -674,7 +662,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public String[] getProperties() {
|
||||
private String[] getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -689,7 +677,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* as they are used to get the imported and exported properties.
|
||||
* </p>
|
||||
*/
|
||||
public void initialiseId(BeanDescriptorInitContext initContext) {
|
||||
void initialiseId(BeanDescriptorInitContext initContext) {
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("BeanDescriptor initialise " + fullName);
|
||||
@@ -783,7 +771,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Perform last initialisation for the descriptor.
|
||||
*/
|
||||
public void initLast() {
|
||||
void initLast() {
|
||||
|
||||
for (BeanProperty prop : propertiesNonTransient) {
|
||||
if (prop.isUnique()) {
|
||||
@@ -825,7 +813,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* Initialise the document mapping.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initialiseDocMapping() {
|
||||
void initialiseDocMapping() {
|
||||
for (BeanPropertyAssocMany<?> many : propertiesMany) {
|
||||
many.initialisePostTarget();
|
||||
}
|
||||
@@ -840,7 +828,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
cacheHelp.deriveNotifyFlags();
|
||||
}
|
||||
|
||||
public void initInheritInfo() {
|
||||
void initInheritInfo() {
|
||||
if (inheritInfo != null) {
|
||||
// need to check every BeanDescriptor in the inheritance hierarchy
|
||||
if (saveRecurseSkippable) {
|
||||
@@ -894,7 +882,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Return the ReadAuditPrepare for preparing read audit events prior to logging.
|
||||
*/
|
||||
public ReadAuditPrepare getReadAuditPrepare() {
|
||||
private ReadAuditPrepare getReadAuditPrepare() {
|
||||
return ebeanServer.getReadAuditPrepare();
|
||||
}
|
||||
|
||||
@@ -980,7 +968,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Populate the diff for inserts with flattened non-null property values.
|
||||
*/
|
||||
protected void jsonWriteForInsert(SpiJsonWriter jsonWriter, EntityBean newBean) throws IOException {
|
||||
void jsonWriteForInsert(SpiJsonWriter jsonWriter, EntityBean newBean) throws IOException {
|
||||
jsonWriter.writeStartObject();
|
||||
for (BeanProperty prop : propertiesBaseScalar) {
|
||||
prop.jsonWriteForInsert(jsonWriter, newBean);
|
||||
@@ -1057,7 +1045,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
elDeployCache.put(fkey.getName(), fkey);
|
||||
}
|
||||
|
||||
public void initialiseFkeys() {
|
||||
void initialiseFkeys() {
|
||||
for (BeanPropertyAssocOne<?> aPropertiesOneImported : propertiesOneImported) {
|
||||
if (!aPropertiesOneImported.isFormula()) {
|
||||
aPropertiesOneImported.addFkey();
|
||||
@@ -1296,13 +1284,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return cacheHelp.getNaturalKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is bean or query caching for this type.
|
||||
*/
|
||||
public boolean isCaching() {
|
||||
return cacheHelp.isCaching();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is currently bean caching for this type of bean.
|
||||
*/
|
||||
@@ -1515,7 +1496,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Invalidate parts of cache due to SqlUpdate or external modification etc.
|
||||
*/
|
||||
public void cachePersistTableIUD(TableIUD tableIUD, CacheChangeSet changeSet) {
|
||||
void cachePersistTableIUD(TableIUD tableIUD, CacheChangeSet changeSet) {
|
||||
cacheHelp.persistTableIUD(tableIUD, changeSet);
|
||||
}
|
||||
|
||||
@@ -1633,7 +1614,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return new DeployUpdateParser(this).parse(ormUpdateStatement);
|
||||
}
|
||||
|
||||
public void collectQueryPlans(QueryPlanRequest request) {
|
||||
void collectQueryPlans(QueryPlanRequest request) {
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
if (request.includeLabel(queryPlan.getLabel())) {
|
||||
queryPlan.collectQueryPlan(request);
|
||||
@@ -1664,7 +1645,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Trim query plans not used since the passed in epoch time.
|
||||
*/
|
||||
public List<CQueryPlan> trimQueryPlans(long unusedSince) {
|
||||
List<CQueryPlan> trimQueryPlans(long unusedSince) {
|
||||
|
||||
List<CQueryPlan> list = new ArrayList<>();
|
||||
|
||||
@@ -1730,7 +1711,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* Return true if save does not recurse to other beans. That is return true if
|
||||
* there are no assoc one or assoc many beans that cascade save.
|
||||
*/
|
||||
public boolean isSaveRecurseSkippable() {
|
||||
boolean isSaveRecurseSkippable() {
|
||||
return saveRecurseSkippable;
|
||||
}
|
||||
|
||||
@@ -1738,7 +1719,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* Return true if delete does not recurse to other beans. That is return true
|
||||
* if there are no assoc one or assoc many beans that cascade delete.
|
||||
*/
|
||||
public boolean isDeleteRecurseSkippable() {
|
||||
boolean isDeleteRecurseSkippable() {
|
||||
return deleteRecurseSkippable;
|
||||
}
|
||||
|
||||
@@ -1820,7 +1801,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Return a raw expression for 'where parent id in ...' clause.
|
||||
*/
|
||||
public String getParentIdInExpr(int parentIdSize, String rawWhere) {
|
||||
String getParentIdInExpr(int parentIdSize, String rawWhere) {
|
||||
String inClause = idBinder.getIdInValueExpr(false, parentIdSize);
|
||||
return idBinder.isIdInExpandedForm() ? inClause : rawWhere + inClause;
|
||||
}
|
||||
@@ -1836,7 +1817,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Return true if this bean type has a simple single Id property.
|
||||
*/
|
||||
public boolean isSimpleId() {
|
||||
boolean isSimpleId() {
|
||||
return idBinder instanceof IdBinderSimple;
|
||||
}
|
||||
|
||||
@@ -1904,7 +1885,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked
|
||||
* on first access (lazy load) or immediately (eager load)
|
||||
*/
|
||||
public EntityBean createEntityBean(boolean isNew) {
|
||||
private EntityBean createEntityBean(boolean isNew) {
|
||||
if (prototypeEntityBean == null) {
|
||||
throw new UnsupportedOperationException("cannot create entity bean for abstract entity " + getName());
|
||||
}
|
||||
@@ -2124,13 +2105,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property value from a bean of this type.
|
||||
*/
|
||||
public Object getValue(EntityBean bean, String property) {
|
||||
return getBeanProperty(property).getValue(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this bean type should use IdGeneration.
|
||||
* <p>
|
||||
@@ -2153,6 +2127,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* Return the class type this BeanDescriptor describes.
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public Class<T> getBeanType() {
|
||||
return beanType;
|
||||
}
|
||||
@@ -2165,6 +2140,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
@@ -2173,6 +2149,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* Return the short name of the entity bean.
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -2255,7 +2232,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
/**
|
||||
* Return the cache key for the given bean (based on id value).
|
||||
*/
|
||||
public String cacheKeyForBean(EntityBean bean) {
|
||||
String cacheKeyForBean(EntityBean bean) {
|
||||
return cacheKey(idProperty.getValue(bean));
|
||||
}
|
||||
|
||||
@@ -2292,7 +2269,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* The usage is to provide simple id types for JSON processing (for embeddedId's).
|
||||
* </p>
|
||||
*/
|
||||
public Object convertIdFromJson(Object idValue) {
|
||||
Object convertIdFromJson(Object idValue) {
|
||||
return idBinder.convertIdFromJson(idValue);
|
||||
}
|
||||
|
||||
@@ -2517,7 +2494,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return elProp;
|
||||
}
|
||||
|
||||
protected ElPropertyValue buildElGetValue(String propName, ElPropertyChainBuilder chain, boolean propertyDeploy) {
|
||||
ElPropertyValue buildElGetValue(String propName, ElPropertyChainBuilder chain, boolean propertyDeploy) {
|
||||
|
||||
if (propertyDeploy && chain != null) {
|
||||
ElPropertyDeploy fk = elDeployCache.get(propName);
|
||||
@@ -2576,7 +2553,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
*/
|
||||
private STreeProperty findSqlTreeFormula(String formula, String path) {
|
||||
String key = formula + "-" + path;
|
||||
return dynamicProperty.computeIfAbsent(key, (fullKey) -> new FormulaPropertyPath(this, formula, path).build());
|
||||
return dynamicProperty.computeIfAbsent(key, (fullKey) -> FormulaPropertyPath.create(this, formula, path));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2633,13 +2610,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the server this BeanDescriptor belongs to.
|
||||
*/
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this bean can cache sharable instances.
|
||||
* <p>
|
||||
@@ -2658,11 +2628,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return autoTunable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isElementType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Inheritance mapping information. This will be null if this type
|
||||
* of bean is not involved in any ORM inheritance mapping.
|
||||
@@ -2935,7 +2900,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
softDeleteProperty.setSoftDeleteValue(bean);
|
||||
}
|
||||
|
||||
public String getSoftDeleteDbSet() {
|
||||
String getSoftDeleteDbSet() {
|
||||
return softDeleteProperty.getSoftDeleteDbSet();
|
||||
}
|
||||
|
||||
@@ -2957,7 +2922,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if this entity type is draftable.
|
||||
*/
|
||||
@@ -3007,7 +2971,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
}
|
||||
}
|
||||
|
||||
public void setUnmappedJson(EntityBean bean, Map<String, Object> unmappedProperties) {
|
||||
void setUnmappedJson(EntityBean bean, Map<String, Object> unmappedProperties) {
|
||||
if (unmappedJson != null) {
|
||||
unmappedJson.setValueIntercept(bean, unmappedProperties);
|
||||
}
|
||||
@@ -3148,6 +3112,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Collection<? extends Property> allProperties() {
|
||||
return propertiesAll();
|
||||
}
|
||||
@@ -3236,7 +3201,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return ebi.isReference() || hasIdPropertyOnly(ebi);
|
||||
}
|
||||
|
||||
public boolean hasIdPropertyOnly(EntityBeanIntercept ebi) {
|
||||
boolean hasIdPropertyOnly(EntityBeanIntercept ebi) {
|
||||
return ebi.hasIdOnly(idPropertyIndex);
|
||||
}
|
||||
|
||||
@@ -3244,11 +3209,11 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return ebi.isLoadedProperty(idPropertyIndex);
|
||||
}
|
||||
|
||||
public boolean hasIdValue(EntityBean bean) {
|
||||
boolean hasIdValue(EntityBean bean) {
|
||||
return (idProperty != null && !DmlUtil.isNullOrZero(idProperty.getValue(bean)));
|
||||
}
|
||||
|
||||
public boolean hasVersionProperty(EntityBeanIntercept ebi) {
|
||||
boolean hasVersionProperty(EntityBeanIntercept ebi) {
|
||||
return versionPropertyIndex > -1 && ebi.isLoadedProperty(versionPropertyIndex);
|
||||
}
|
||||
|
||||
@@ -3497,7 +3462,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
jsonHelp.jsonWriteDirty(writeJson, bean, dirtyProps);
|
||||
}
|
||||
|
||||
protected void jsonWriteDirtyProperties(SpiJsonWriter writeJson, EntityBean bean, boolean[] dirtyProps) throws IOException {
|
||||
void jsonWriteDirtyProperties(SpiJsonWriter writeJson, EntityBean bean, boolean[] dirtyProps) throws IOException {
|
||||
jsonHelp.jsonWriteDirtyProperties(writeJson, bean, dirtyProps);
|
||||
}
|
||||
|
||||
@@ -3521,7 +3486,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
jsonHelp.jsonWrite(writeJson, bean, key);
|
||||
}
|
||||
|
||||
protected void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) throws IOException {
|
||||
void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) {
|
||||
jsonHelp.jsonWriteProperties(writeJson, bean);
|
||||
}
|
||||
|
||||
@@ -3529,7 +3494,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
return jsonHelp.jsonRead(jsonRead, path, true);
|
||||
}
|
||||
|
||||
public T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, false);
|
||||
}
|
||||
|
||||
@@ -3560,5 +3525,4 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
getInheritInfo().visitChildren(info -> visitor.accept(info.desc()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @param <T> The entity bean type
|
||||
*/
|
||||
public final class BeanDescriptorDraftHelp<T> {
|
||||
final class BeanDescriptorDraftHelp<T> {
|
||||
|
||||
private final BeanDescriptor<T> desc;
|
||||
|
||||
@@ -19,7 +19,7 @@ public final class BeanDescriptorDraftHelp<T> {
|
||||
|
||||
private final BeanProperty[] resetProperties;
|
||||
|
||||
public BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
|
||||
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
|
||||
this.desc = desc;
|
||||
this.draftDirty = desc.getDraftDirty();
|
||||
this.resetProperties = resetProperties();
|
||||
@@ -39,13 +39,13 @@ public final class BeanDescriptorDraftHelp<T> {
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new BeanProperty[list.size()]);
|
||||
return list.toArray(new BeanProperty[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of all the 'reset properties' to null on the draft bean.
|
||||
*/
|
||||
public boolean draftReset(T draftBean) {
|
||||
boolean draftReset(T draftBean) {
|
||||
|
||||
EntityBean draftEntityBean = (EntityBean) draftBean;
|
||||
|
||||
@@ -102,7 +102,7 @@ public final class BeanDescriptorDraftHelp<T> {
|
||||
/**
|
||||
* Fetch draftable element relationships.
|
||||
*/
|
||||
public void draftQueryOptimise(Query<T> query) {
|
||||
void draftQueryOptimise(Query<T> query) {
|
||||
|
||||
BeanPropertyAssocOne<?>[] one = desc.propertiesOne();
|
||||
for (BeanPropertyAssocOne<?> anOne : one) {
|
||||
|
||||
@@ -32,11 +32,6 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
|
||||
return props[0].getScalarType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isElementType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our entity beans used are somewhat fake ones (ElementEntityBean) such that we hold the unidirectional property
|
||||
* value (foreign key) and the actual element collection value (scalar or embedded plus map key).
|
||||
|
||||
@@ -663,7 +663,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
return (BeanManager<T>) getBeanManager(entityType.getName());
|
||||
}
|
||||
|
||||
public BeanManager<?> getBeanManager(String beanClassName) {
|
||||
private BeanManager<?> getBeanManager(String beanClassName) {
|
||||
return beanManagerMap.get(beanClassName);
|
||||
}
|
||||
|
||||
@@ -815,7 +815,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
return new BeanTable(beanTable, this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void readEntityRelationships() {
|
||||
|
||||
// We only perform 'circular' checks etc after we have
|
||||
@@ -1650,13 +1649,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
return changeLogListener;
|
||||
}
|
||||
|
||||
public void addPrimaryKeyJoin(DeployBeanPropertyAssocOne<?> prop) {
|
||||
private void addPrimaryKeyJoin(DeployBeanPropertyAssocOne<?> prop) {
|
||||
|
||||
String baseTable = prop.getDesc().getBaseTable();
|
||||
DeployTableJoin inverse = prop.getTableJoin().createInverse(baseTable);
|
||||
|
||||
TableJoin inverseJoin = new TableJoin(inverse);
|
||||
|
||||
TableJoin inverseJoin = new TableJoin(inverse, prop.getForeignKey());
|
||||
DeployBeanInfo<?> target = deployInfoMap.get(prop.getTargetType());
|
||||
target.setPrimaryKeyJoin(inverseJoin);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package io.ebeaninternal.server.deploy;
|
||||
public class BeanEmbeddedMeta {
|
||||
|
||||
|
||||
final BeanProperty[] properties;
|
||||
private final BeanProperty[] properties;
|
||||
|
||||
public BeanEmbeddedMeta(BeanProperty[] properties) {
|
||||
BeanEmbeddedMeta(BeanProperty[] properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Map;
|
||||
* Creates BeanProperties for Embedded beans that have deployment information
|
||||
* such as the actual DB column name and table alias.
|
||||
*/
|
||||
public class BeanEmbeddedMetaFactory {
|
||||
class BeanEmbeddedMetaFactory {
|
||||
|
||||
/**
|
||||
* Create BeanProperties for embedded beans using the deployment specific DB column name and table alias.
|
||||
|
||||
@@ -11,25 +11,24 @@ import java.util.List;
|
||||
/**
|
||||
* Default implementation for BeanFinderFactory.
|
||||
*/
|
||||
public class BeanFinderManager {
|
||||
class BeanFinderManager {
|
||||
|
||||
final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
|
||||
|
||||
private final List<BeanFindController> list;
|
||||
|
||||
public BeanFinderManager(BootupClasses bootupClasses) {
|
||||
BeanFinderManager(BootupClasses bootupClasses) {
|
||||
list = bootupClasses.getBeanFindControllers();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanPersistController for a given entity type.
|
||||
*/
|
||||
public void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
|
||||
void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanFindController c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
logger.debug("BeanFindController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
|
||||
@@ -141,11 +141,11 @@ class BeanLifecycleAdapterFactory {
|
||||
/**
|
||||
* Utility method to covert List of Method into array (because we care about performance here).
|
||||
*/
|
||||
static Method[] toArray(List<Method> methodList) {
|
||||
return methodList.toArray(new Method[methodList.size()]);
|
||||
private static Method[] toArray(List<Method> methodList) {
|
||||
return methodList.toArray(new Method[0]);
|
||||
}
|
||||
|
||||
static RuntimeException unwrapException(ReflectiveOperationException e) {
|
||||
private static RuntimeException unwrapException(ReflectiveOperationException e) {
|
||||
if (e instanceof InvocationTargetException) {
|
||||
Throwable targetException = ((InvocationTargetException)e).getTargetException();
|
||||
if (targetException instanceof RuntimeException) {
|
||||
|
||||
@@ -7,16 +7,15 @@ import io.ebeaninternal.server.persist.dml.DmlBeanPersisterFactory;
|
||||
/**
|
||||
* Creates BeanManagers.
|
||||
*/
|
||||
public class BeanManagerFactory {
|
||||
class BeanManagerFactory {
|
||||
|
||||
final BeanPersisterFactory persisterFactory;
|
||||
private final BeanPersisterFactory persisterFactory;
|
||||
|
||||
public BeanManagerFactory(DatabasePlatform dbPlatform) {
|
||||
BeanManagerFactory(DatabasePlatform dbPlatform) {
|
||||
persisterFactory = new DmlBeanPersisterFactory(dbPlatform);
|
||||
}
|
||||
|
||||
public <T> BeanManager<T> create(BeanDescriptor<T> desc) {
|
||||
|
||||
return new BeanManager<>(desc, persisterFactory.create(desc));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import io.ebeanservice.docstore.api.support.DocStructure;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -65,19 +66,19 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Flag to mark this is the id property.
|
||||
*/
|
||||
final boolean id;
|
||||
private final boolean id;
|
||||
|
||||
final boolean importedPrimaryKey;
|
||||
private final boolean importedPrimaryKey;
|
||||
|
||||
/**
|
||||
* Flag to make this as a dummy property for unidirecitonal relationships.
|
||||
*/
|
||||
final boolean unidirectionalShadow;
|
||||
private final boolean unidirectionalShadow;
|
||||
|
||||
/**
|
||||
* Flag set if this maps to the inheritance discriminator column
|
||||
*/
|
||||
final boolean discriminator;
|
||||
private final boolean discriminator;
|
||||
|
||||
/**
|
||||
* Flag to mark the property as embedded. This could be on
|
||||
@@ -89,55 +90,55 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Flag indicating if this the version property.
|
||||
*/
|
||||
final boolean version;
|
||||
private final boolean version;
|
||||
|
||||
final boolean naturalKey;
|
||||
private final boolean naturalKey;
|
||||
|
||||
/**
|
||||
* Set if this property is nullable.
|
||||
*/
|
||||
final boolean nullable;
|
||||
private final boolean nullable;
|
||||
|
||||
final boolean unique;
|
||||
private final boolean unique;
|
||||
|
||||
/**
|
||||
* Is this property include in database resultSet.
|
||||
*/
|
||||
final boolean dbRead;
|
||||
private final boolean dbRead;
|
||||
|
||||
/**
|
||||
* Include in DB insert.
|
||||
*/
|
||||
final boolean dbInsertable;
|
||||
private final boolean dbInsertable;
|
||||
|
||||
/**
|
||||
* Include in DB update.
|
||||
*/
|
||||
final boolean dbUpdatable;
|
||||
private final boolean dbUpdatable;
|
||||
|
||||
/**
|
||||
* True if the property is based on a SECONDARY table.
|
||||
*/
|
||||
final boolean secondaryTable;
|
||||
private final boolean secondaryTable;
|
||||
|
||||
final TableJoin secondaryTableJoin;
|
||||
final String secondaryTableJoinPrefix;
|
||||
private final TableJoin secondaryTableJoin;
|
||||
private final String secondaryTableJoinPrefix;
|
||||
|
||||
/**
|
||||
* The property is inherited from a super class.
|
||||
*/
|
||||
final boolean inherited;
|
||||
private final boolean inherited;
|
||||
|
||||
final Class<?> owningType;
|
||||
private final Class<?> owningType;
|
||||
|
||||
final boolean local;
|
||||
private final boolean local;
|
||||
|
||||
/**
|
||||
* True if the property is a Clob, Blob LongVarchar or LongVarbinary.
|
||||
*/
|
||||
final boolean lob;
|
||||
private final boolean lob;
|
||||
|
||||
final boolean fetchEager;
|
||||
private final boolean fetchEager;
|
||||
|
||||
final boolean isTransient;
|
||||
|
||||
@@ -151,62 +152,62 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* The reflected field.
|
||||
*/
|
||||
final Field field;
|
||||
private final Field field;
|
||||
|
||||
/**
|
||||
* The bean type.
|
||||
*/
|
||||
final Class<?> propertyType;
|
||||
private final Class<?> propertyType;
|
||||
|
||||
final String dbBind;
|
||||
private final String dbBind;
|
||||
|
||||
/**
|
||||
* The database column. This can include quoted identifiers.
|
||||
*/
|
||||
final String dbColumn;
|
||||
|
||||
final String elPrefix;
|
||||
private final String elPrefix;
|
||||
final String elPlaceHolder;
|
||||
final String elPlaceHolderEncrypted;
|
||||
|
||||
/**
|
||||
* Select part of a SQL Formula used to populate this property.
|
||||
*/
|
||||
final String sqlFormulaSelect;
|
||||
private final String sqlFormulaSelect;
|
||||
|
||||
/**
|
||||
* Join part of a SQL Formula.
|
||||
*/
|
||||
final String sqlFormulaJoin;
|
||||
|
||||
final String aggregation;
|
||||
private final String aggregation;
|
||||
|
||||
final boolean formula;
|
||||
private final boolean formula;
|
||||
|
||||
/**
|
||||
* Set to true if stored encrypted.
|
||||
*/
|
||||
final boolean dbEncrypted;
|
||||
private final boolean dbEncrypted;
|
||||
|
||||
final boolean localEncrypted;
|
||||
private final boolean localEncrypted;
|
||||
|
||||
final int dbEncryptedType;
|
||||
private final int dbEncryptedType;
|
||||
|
||||
/**
|
||||
* The jdbc data type this maps to.
|
||||
*/
|
||||
final int dbType;
|
||||
private final int dbType;
|
||||
|
||||
final boolean excludedFromHistory;
|
||||
|
||||
/**
|
||||
* Generator for insert or update timestamp etc.
|
||||
*/
|
||||
final GeneratedProperty generatedProperty;
|
||||
private final GeneratedProperty generatedProperty;
|
||||
|
||||
final BeanPropertyGetter getter;
|
||||
private final BeanPropertyGetter getter;
|
||||
|
||||
final BeanPropertySetter setter;
|
||||
private final BeanPropertySetter setter;
|
||||
|
||||
final BeanDescriptor<?> descriptor;
|
||||
|
||||
@@ -217,56 +218,56 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
@SuppressWarnings("rawtypes")
|
||||
final ScalarType scalarType;
|
||||
|
||||
final DocPropertyOptions docOptions;
|
||||
private final DocPropertyOptions docOptions;
|
||||
|
||||
/**
|
||||
* The length or precision for DB column.
|
||||
*/
|
||||
final int dbLength;
|
||||
private final int dbLength;
|
||||
|
||||
/**
|
||||
* The scale for DB column (decimal).
|
||||
*/
|
||||
final int dbScale;
|
||||
private final int dbScale;
|
||||
|
||||
/**
|
||||
* Deployment defined DB column definition.
|
||||
*/
|
||||
final String dbColumnDefn;
|
||||
private final String dbColumnDefn;
|
||||
|
||||
/**
|
||||
* DB Column default value for DDL definition (FALSE, NOW etc).
|
||||
*/
|
||||
final String dbColumnDefault;
|
||||
final List<DbMigrationInfo> dbMigrationInfos;
|
||||
private final String dbColumnDefault;
|
||||
private final List<DbMigrationInfo> dbMigrationInfos;
|
||||
|
||||
/**
|
||||
* Database DDL column comment.
|
||||
*/
|
||||
final String dbComment;
|
||||
private final String dbComment;
|
||||
|
||||
final DbEncryptFunction dbEncryptFunction;
|
||||
private final DbEncryptFunction dbEncryptFunction;
|
||||
|
||||
int deployOrder;
|
||||
private int deployOrder;
|
||||
|
||||
final boolean jsonSerialize;
|
||||
final boolean jsonDeserialize;
|
||||
final boolean unmappedJson;
|
||||
final boolean tenantId;
|
||||
private final boolean unmappedJson;
|
||||
private final boolean tenantId;
|
||||
|
||||
final boolean draft;
|
||||
private final boolean draft;
|
||||
|
||||
final boolean draftOnly;
|
||||
private final boolean draftOnly;
|
||||
|
||||
final boolean draftDirty;
|
||||
private final boolean draftDirty;
|
||||
|
||||
final boolean draftReset;
|
||||
private final boolean draftReset;
|
||||
|
||||
final boolean softDelete;
|
||||
private final boolean softDelete;
|
||||
|
||||
final String softDeleteDbSet;
|
||||
private final String softDeleteDbSet;
|
||||
|
||||
final String softDeleteDbPredicate;
|
||||
private final String softDeleteDbPredicate;
|
||||
|
||||
public BeanProperty(DeployBeanProperty deploy) {
|
||||
this(null, deploy);
|
||||
@@ -545,7 +546,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return dbEncryptFunction.getDecryptSql(this.getDbColumn());
|
||||
}
|
||||
|
||||
public String getDecryptSql(String tableAlias) {
|
||||
private String getDecryptSql(String tableAlias) {
|
||||
return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.getDbColumn());
|
||||
}
|
||||
|
||||
@@ -702,7 +703,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return true if this object is part of an inheritance hierarchy.
|
||||
*/
|
||||
public boolean isInherited() {
|
||||
private boolean isInherited() {
|
||||
return inherited;
|
||||
}
|
||||
|
||||
@@ -728,21 +729,21 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the DB literal expression to set the deleted state to true.
|
||||
*/
|
||||
public String getSoftDeleteDbSet() {
|
||||
String getSoftDeleteDbSet() {
|
||||
return softDeleteDbSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB literal predicate used to filter out soft deleted rows from a query.
|
||||
*/
|
||||
public String getSoftDeleteDbPredicate(String tableAlias) {
|
||||
String getSoftDeleteDbPredicate(String tableAlias) {
|
||||
return tableAlias + softDeleteDbPredicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the soft delete property value on the bean without invoking lazy loading.
|
||||
*/
|
||||
public void setSoftDeleteValue(EntityBean bean) {
|
||||
void setSoftDeleteValue(EntityBean bean) {
|
||||
// assumes boolean deleted true being set which is ok limitation for now
|
||||
setValue(bean, true);
|
||||
bean._ebean_getIntercept().setChangedProperty(propertyIndex);
|
||||
@@ -909,7 +910,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the name of the property.
|
||||
*/
|
||||
@Override
|
||||
@Override @Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -1018,7 +1019,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return true if the mutable value is considered dirty.
|
||||
* This is only used for 'mutable' scalar types like hstore etc.
|
||||
*/
|
||||
public boolean isDirtyValue(Object value) {
|
||||
boolean isDirtyValue(Object value) {
|
||||
return scalarType.isDirty(value);
|
||||
}
|
||||
|
||||
@@ -1061,14 +1062,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the DB scale for numeric columns.
|
||||
*/
|
||||
public int getDbScale() {
|
||||
private int getDbScale() {
|
||||
return dbScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a specific column DDL definition if specified (otherwise null).
|
||||
*/
|
||||
public String getDbColumnDefn() {
|
||||
private String getDbColumnDefn() {
|
||||
return dbColumnDefn;
|
||||
}
|
||||
|
||||
@@ -1112,7 +1113,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the bean Field associated with this property.
|
||||
*/
|
||||
public Field getField() {
|
||||
private Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
@@ -1148,14 +1149,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return true if this is a generated property mapping to @WhenCreated or @CreatedTimestamp.
|
||||
*/
|
||||
public boolean isGeneratedWhenCreated() {
|
||||
boolean isGeneratedWhenCreated() {
|
||||
return generatedProperty instanceof GeneratedWhenCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is a generated property mapping to @WhenModified or @UpdatedTimestamp.
|
||||
*/
|
||||
public boolean isGeneratedWhenModified() {
|
||||
boolean isGeneratedWhenModified() {
|
||||
return generatedProperty instanceof GeneratedWhenModified;
|
||||
}
|
||||
|
||||
@@ -1191,7 +1192,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return true if this is a draftOnly property on a non-asDraft query and as such this
|
||||
* property should not be included in a sql query.
|
||||
*/
|
||||
protected boolean ignoreDraftOnlyProperty(boolean draftQuery) {
|
||||
private boolean ignoreDraftOnlyProperty(boolean draftQuery) {
|
||||
return draftOnly && !draftQuery;
|
||||
}
|
||||
|
||||
@@ -1232,7 +1233,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Perform DB to Logical type conversion (if necessary).
|
||||
*/
|
||||
public Object convertToLogicalType(Object value) {
|
||||
private Object convertToLogicalType(Object value) {
|
||||
if (scalarType != null) {
|
||||
return scalarType.toBeanType(value);
|
||||
}
|
||||
@@ -1258,12 +1259,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
public static boolean isLobType(int type) {
|
||||
switch (type) {
|
||||
case Types.CLOB:
|
||||
return true;
|
||||
case Types.BLOB:
|
||||
return true;
|
||||
case Types.LONGVARBINARY:
|
||||
return true;
|
||||
case Types.LONGVARCHAR:
|
||||
case Types.LONGVARBINARY:
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -1311,13 +1309,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return excludedFromHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is a ManyToMany with history support (on the intersection table).
|
||||
*/
|
||||
public boolean isManyToManyWithHistory() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this property hold unmapped JSON.
|
||||
*/
|
||||
@@ -1358,7 +1349,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return true if this property is reset/cleared on publish (on the draft bean).
|
||||
*/
|
||||
public boolean isDraftReset() {
|
||||
boolean isDraftReset() {
|
||||
return draftReset;
|
||||
}
|
||||
|
||||
@@ -1386,7 +1377,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return true if this property is included in database queries.
|
||||
*/
|
||||
public boolean isDbRead() {
|
||||
private boolean isDbRead() {
|
||||
return dbRead;
|
||||
}
|
||||
|
||||
@@ -1401,7 +1392,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the property type.
|
||||
*/
|
||||
@Override
|
||||
@Override @Nonnull
|
||||
public Class<?> getPropertyType() {
|
||||
return propertyType;
|
||||
}
|
||||
@@ -1533,7 +1524,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Populate diff map comparing the property values.
|
||||
*/
|
||||
public void diffVal(String prefix, Map<String, ValuePair> map, Object newVal, Object oldVal) {
|
||||
void diffVal(String prefix, Map<String, ValuePair> map, Object newVal, Object oldVal) {
|
||||
if (!ValueUtil.areEqual(newVal, oldVal)) {
|
||||
String propName = (prefix == null) ? name : prefix + "." + name;
|
||||
map.put(propName, new ValuePair(newVal, oldVal));
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Derived list of exported property and matching foreignKey
|
||||
*/
|
||||
protected ExportedProperty[] exportedProperties;
|
||||
ExportedProperty[] exportedProperties;
|
||||
|
||||
/**
|
||||
* Persist settings.
|
||||
@@ -70,7 +70,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* The type of the joined bean.
|
||||
*/
|
||||
final Class<T> targetType;
|
||||
private final Class<T> targetType;
|
||||
|
||||
/**
|
||||
* The join table information.
|
||||
@@ -79,18 +79,18 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
|
||||
final String mappedBy;
|
||||
|
||||
final String docStoreDoc;
|
||||
private final String docStoreDoc;
|
||||
|
||||
final String extraWhere;
|
||||
private final String extraWhere;
|
||||
|
||||
final int fetchPreference;
|
||||
private final int fetchPreference;
|
||||
|
||||
boolean saveRecurseSkippable;
|
||||
private boolean saveRecurseSkippable;
|
||||
|
||||
/**
|
||||
* Construct the property.
|
||||
*/
|
||||
public BeanPropertyAssoc(BeanDescriptor<?> descriptor, DeployBeanPropertyAssoc<T> deploy) {
|
||||
BeanPropertyAssoc(BeanDescriptor<?> descriptor, DeployBeanPropertyAssoc<T> deploy) {
|
||||
super(descriptor, deploy);
|
||||
this.foreignKey = deploy.getForeignKey();
|
||||
this.extraWhere = InternString.intern(deploy.getExtraWhere());
|
||||
@@ -107,7 +107,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Copy constructor for ManyToOne inside Embeddable.
|
||||
*/
|
||||
public BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) {
|
||||
@SuppressWarnings("unchecked")
|
||||
BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) {
|
||||
super(source, override);
|
||||
foreignKey = source.foreignKey;
|
||||
extraWhere = source.extraWhere;
|
||||
@@ -154,10 +155,24 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
return foreignKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if foreign key constraint is enabled on this relationship (not disabled).
|
||||
*/
|
||||
public boolean hasForeignKeyConstraint() {
|
||||
return foreignKey == null || !foreignKey.isNoConstraint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if foreign key index is enabled on this relationship (not disabled).
|
||||
*/
|
||||
public boolean hasForeignKeyIndex() {
|
||||
return foreignKey == null || !foreignKey.isNoIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ElPropertyValue for a *ToOne or *ToMany.
|
||||
*/
|
||||
protected ElPropertyValue createElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) {
|
||||
ElPropertyValue createElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) {
|
||||
|
||||
// associated or embedded bean
|
||||
BeanDescriptor<?> embDesc = getTargetDescriptor();
|
||||
@@ -227,7 +242,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
|
||||
/**
|
||||
* Create a new query for the target type.
|
||||
*
|
||||
* <p>
|
||||
* We use target descriptor rather than target property type to support ElementCollection.
|
||||
*/
|
||||
public SpiQuery<T> newQuery(SpiEbeanServer server) {
|
||||
@@ -254,12 +269,11 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Return true if REFRESH should cascade.
|
||||
*/
|
||||
public boolean isCascadeRefresh() {
|
||||
boolean isCascadeRefresh() {
|
||||
return cascadeInfo.isRefresh();
|
||||
}
|
||||
|
||||
public boolean isSaveRecurseSkippable(Object bean) {
|
||||
|
||||
return saveRecurseSkippable && bean instanceof EntityBean && !((EntityBean) bean)._ebean_getIntercept().isNewOrDirty();
|
||||
}
|
||||
|
||||
@@ -283,14 +297,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
|
||||
BeanDescriptor<?> targetDesc = getTargetDescriptor();
|
||||
BeanProperty idProp = targetDesc.getIdProperty();
|
||||
if (idProp != null) {
|
||||
Object value = idProp.getValue(bean);
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// all the unique properties are non-null
|
||||
return true;
|
||||
return idProp == null || idProp.getValue(bean) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +324,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Return the elastic search doc for this embedded property.
|
||||
*/
|
||||
public String getDocStoreDoc() {
|
||||
private String getDocStoreDoc() {
|
||||
return docStoreDoc;
|
||||
}
|
||||
|
||||
@@ -347,7 +355,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Include the property in the document store by default.
|
||||
*/
|
||||
protected void docStoreIncludeByDefault(PathProperties pathProps) {
|
||||
void docStoreIncludeByDefault(PathProperties pathProps) {
|
||||
pathProps.addToPath(null, name);
|
||||
}
|
||||
|
||||
@@ -429,7 +437,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* Build the list of imported property. Matches BeanProperty from the target
|
||||
* descriptor back to local database columns in the TableJoin.
|
||||
*/
|
||||
protected ImportedId createImportedId(BeanPropertyAssoc<?> owner, BeanDescriptor<?> target, TableJoin join) {
|
||||
ImportedId createImportedId(BeanPropertyAssoc<?> owner, BeanDescriptor<?> target, TableJoin join) {
|
||||
|
||||
BeanProperty idProp = target.getIdProperty();
|
||||
BeanProperty[] others = target.propertiesBaseScalar();
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.ebean.bean.BeanCollection.ModifyListenMode;
|
||||
import io.ebean.bean.BeanCollectionAdd;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebean.plugin.PropertyAssocMany;
|
||||
import io.ebean.text.PathProperties;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
@@ -27,7 +28,6 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -37,7 +37,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Property mapped to a List Set or Map.
|
||||
*/
|
||||
public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany {
|
||||
public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany, PropertyAssocMany {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BeanPropertyAssocMany.class);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Descriptor for the 'target' when the property maps to an element collection.
|
||||
*/
|
||||
BeanDescriptor<T> elementDescriptor;
|
||||
final BeanDescriptor<T> elementDescriptor;
|
||||
|
||||
/**
|
||||
* Order by used when fetch joining the associated many.
|
||||
@@ -105,7 +105,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Property on the 'child' bean that links back to the 'master'.
|
||||
*/
|
||||
protected BeanPropertyAssocOne<?> childMasterProperty;
|
||||
private BeanPropertyAssocOne<?> childMasterProperty;
|
||||
|
||||
private String childMasterIdProperty;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Initialise after the target bean descriptors have been all set.
|
||||
*/
|
||||
public void initialisePostTarget() {
|
||||
void initialisePostTarget() {
|
||||
if (childMasterProperty != null) {
|
||||
BeanProperty masterId = childMasterProperty.getTargetDescriptor().getIdProperty();
|
||||
if (masterId != null) { // in docstore only, the master-id may be not available
|
||||
@@ -348,6 +348,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*
|
||||
* Helper method used by Elastic integration when loading with a persistence context.
|
||||
*/
|
||||
@Override
|
||||
public void lazyLoadMany(EntityBean current) {
|
||||
EntityBean parentBean = childMasterProperty.getValueAsEntityBean(current);
|
||||
if (parentBean != null) {
|
||||
@@ -424,7 +425,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(DbReadContext ctx) throws SQLException {
|
||||
public Object read(DbReadContext ctx) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -636,8 +637,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
return help.createEmpty(parentBean);
|
||||
}
|
||||
|
||||
public BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
||||
return help.getBeanCollectionAdd(bc, mapKey);
|
||||
private BeanCollectionAdd getBeanCollectionAdd(Object bc) {
|
||||
return help.getBeanCollectionAdd(bc, null);
|
||||
}
|
||||
|
||||
public Object getParentId(EntityBean parentBean) {
|
||||
@@ -683,7 +684,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new ExportedProperty[list.size()]);
|
||||
return list.toArray(new ExportedProperty[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,7 +783,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Register the mapping of intersection table to associated draft table.
|
||||
*/
|
||||
public void registerDraftIntersectionTable(BeanDescriptorInitContext initContext) {
|
||||
void registerDraftIntersectionTable(BeanDescriptorInitContext initContext) {
|
||||
if (hasDraftIntersection()) {
|
||||
initContext.addDraftIntersection(intersectionPublishTable, intersectionDraftTable);
|
||||
}
|
||||
@@ -883,7 +884,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void publishMany(EntityBean draft, EntityBean live) {
|
||||
void publishMany(EntityBean draft, EntityBean live) {
|
||||
|
||||
// collections will not be null due to enhancement
|
||||
BeanCollection<T> draftVal = (BeanCollection<T>) getValueIntercept(draft);
|
||||
@@ -955,15 +956,11 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
return targetDescriptor.isDocStoreMapped();
|
||||
}
|
||||
|
||||
public BeanCollectionHelp<T> getHelp() {
|
||||
return help;
|
||||
}
|
||||
|
||||
public void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry<?, ?> entry) throws IOException {
|
||||
void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry<?, ?> entry) throws IOException {
|
||||
elementDescriptor.jsonWriteMapEntry(ctx, entry);
|
||||
}
|
||||
|
||||
public void jsonWriteElementValue(SpiJsonWriter ctx, Object element) {
|
||||
void jsonWriteElementValue(SpiJsonWriter ctx, Object element) {
|
||||
elementDescriptor.jsonWriteElement(ctx, element);
|
||||
}
|
||||
|
||||
@@ -1011,7 +1008,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Read the collection as JSON.
|
||||
*/
|
||||
public Object jsonReadCollection(String json) throws IOException {
|
||||
private Object jsonReadCollection(String json) throws IOException {
|
||||
SpiJsonReader ctx = descriptor.createJsonReader(json);
|
||||
JsonParser parser = ctx.getParser();
|
||||
JsonToken event = parser.nextToken();
|
||||
@@ -1024,7 +1021,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Write the collection to JSON.
|
||||
*/
|
||||
public void jsonWriteCollection(SpiJsonWriter ctx, String name, Object value, boolean explicitInclude) throws IOException {
|
||||
private void jsonWriteCollection(SpiJsonWriter ctx, String name, Object value, boolean explicitInclude) throws IOException {
|
||||
help.jsonWrite(ctx, name, value, explicitInclude);
|
||||
}
|
||||
|
||||
@@ -1038,7 +1035,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
|
||||
BeanCollection<?> collection = createEmpty(parentBean);
|
||||
BeanCollectionAdd add = getBeanCollectionAdd(collection, null);
|
||||
BeanCollectionAdd add = getBeanCollectionAdd(collection);
|
||||
do {
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name);
|
||||
if (detailBean == null) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("insert into ").append(many.targetTable()).append(" (");
|
||||
append(sb, "", ",", "");
|
||||
append(sb);
|
||||
|
||||
Cols cols = new Cols(sb);
|
||||
VisitAllUsing.visitOne(many.targetDescriptor, cols);
|
||||
@@ -59,7 +59,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String insertElementCollection() {
|
||||
String insertElementCollection() {
|
||||
return elementCollectionInsertSql;
|
||||
}
|
||||
|
||||
@@ -191,16 +191,16 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private void append(StringBuilder sb, String tableAlias, String prefix, String suffix) {
|
||||
private void append(StringBuilder sb) {
|
||||
for (int i = 0; i < exportedProperties.length; i++) {
|
||||
String fkColumn = exportedProperties[i].getForeignDbColumn();
|
||||
if (i > 0) {
|
||||
sb.append(prefix);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(tableAlias).append(fkColumn);
|
||||
sb.append(suffix);
|
||||
sb.append(fkColumn);
|
||||
}
|
||||
}
|
||||
|
||||
private String deriveWhereParentIdSql(boolean inClause, String tableAlias) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.ebeaninternal.server.query.SqlBeanLoad;
|
||||
import io.ebeaninternal.server.query.SqlJoinType;
|
||||
import io.ebeaninternal.server.type.DataReader;
|
||||
import io.ebeaninternal.server.type.ScalarDataReader;
|
||||
import io.ebeaninternal.server.type.ScalarType;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
@@ -44,14 +45,15 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
private final boolean orphanRemoval;
|
||||
|
||||
private final boolean primaryKeyExport;
|
||||
private final boolean primaryKeyJoin;
|
||||
|
||||
private AssocOneHelp localHelp;
|
||||
|
||||
protected final BeanProperty[] embeddedProps;
|
||||
final BeanProperty[] embeddedProps;
|
||||
|
||||
private final HashMap<String, BeanProperty> embeddedPropsMap;
|
||||
|
||||
protected ImportedId importedId;
|
||||
ImportedId importedId;
|
||||
|
||||
private String deleteByParentIdSql;
|
||||
private String deleteByParentIdInSql;
|
||||
@@ -74,6 +76,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
|
||||
super(descriptor, deploy);
|
||||
primaryKeyExport = deploy.isPrimaryKeyExport();
|
||||
primaryKeyJoin = deploy.isPrimaryKeyJoin();
|
||||
oneToOne = deploy.isOneToOne();
|
||||
oneToOneExported = deploy.isOneToOneExported();
|
||||
orphanRemoval = deploy.isOrphanRemoval();
|
||||
@@ -99,6 +102,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
public BeanPropertyAssocOne(BeanPropertyAssocOne source, BeanPropertyOverride override) {
|
||||
super(source, override);
|
||||
primaryKeyExport = source.primaryKeyExport;
|
||||
primaryKeyJoin = source.primaryKeyJoin;
|
||||
oneToOne = source.oneToOne;
|
||||
oneToOneExported = source.oneToOneExported;
|
||||
orphanRemoval = source.orphanRemoval;
|
||||
@@ -153,7 +157,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
/**
|
||||
* Derive late in lifecycle cache notification on this relationship.
|
||||
*/
|
||||
public void initialisePostTarget() {
|
||||
void initialisePostTarget() {
|
||||
this.cacheNotifyRelationship = isCacheNotifyRelationship();
|
||||
}
|
||||
|
||||
@@ -356,11 +360,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
|
||||
public boolean hasForeignKey() {
|
||||
return foreignKey == null || !foreignKey.isNoConstraint();
|
||||
}
|
||||
|
||||
public boolean hasForeignKeyIndex() {
|
||||
return foreignKey == null || !foreignKey.isNoIndex();
|
||||
return foreignKey == null || primaryKeyJoin || !foreignKey.isNoConstraint();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,10 +390,11 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
return;
|
||||
}
|
||||
|
||||
String nextPrefix = (prefix == null) ? name : prefix + "." + name;
|
||||
|
||||
if (embedded) {
|
||||
prefix = (prefix == null) ? name : prefix + "." + name;
|
||||
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
|
||||
targetDescriptor.diff(prefix, map, (EntityBean) newEmb, (EntityBean) oldEmb);
|
||||
targetDescriptor.diff(nextPrefix, map, (EntityBean) newEmb, (EntityBean) oldEmb);
|
||||
|
||||
} else {
|
||||
// we are only interested in the Id value
|
||||
@@ -406,8 +407,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
Object newId = (newBean == null) ? null : idProperty.getValue(newBean);
|
||||
Object oldId = (oldBean == null) ? null : idProperty.getValue(oldBean);
|
||||
if (newId != null || oldId != null) {
|
||||
prefix = (prefix == null) ? name : prefix + "." + name;
|
||||
idProperty.diffVal(prefix, map, newId, oldId);
|
||||
idProperty.diffVal(nextPrefix, map, newId, oldId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,6 +465,10 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
return targetDescriptor.getIdProperty();
|
||||
}
|
||||
|
||||
ScalarType getIdScalarType() {
|
||||
return targetDescriptor.getIdProperty().scalarType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Id values from the given bean.
|
||||
*/
|
||||
@@ -577,7 +581,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new ExportedProperty[list.size()]);
|
||||
return list.toArray(new ExportedProperty[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -670,7 +674,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
}
|
||||
|
||||
void setEmbeddedOwner(EntityBean bean, Object value) {
|
||||
private void setEmbeddedOwner(EntityBean bean, Object value) {
|
||||
((EntityBean) value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex);
|
||||
}
|
||||
|
||||
@@ -764,10 +768,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
writeJson.writeNullField(name);
|
||||
|
||||
} else {
|
||||
if (writeJson.isParentBean(value)) {
|
||||
// bi-directional and already rendered parent
|
||||
|
||||
} else {
|
||||
if (!writeJson.isParentBean(value)) {
|
||||
// Hmmm, not writing complex non-entity bean
|
||||
if (value instanceof EntityBean) {
|
||||
writeJson.beginAssocOne(name, bean);
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
|
||||
*/
|
||||
public class BeanPropertyIdClass extends BeanPropertyAssocOne {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BeanPropertyIdClass(BeanDescriptorMap owner, BeanDescriptor descriptor, DeployBeanPropertyAssocOne deploy) {
|
||||
super(owner, descriptor, deploy);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import io.ebeaninternal.server.core.InternString;
|
||||
* Typically this is for Embedded Beans.
|
||||
* </p>
|
||||
*/
|
||||
public class BeanPropertyOverride {
|
||||
class BeanPropertyOverride {
|
||||
|
||||
private final String dbColumn;
|
||||
|
||||
public BeanPropertyOverride(String dbColumn) {
|
||||
BeanPropertyOverride(String dbColumn) {
|
||||
this.dbColumn = InternString.intern(dbColumn);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,25 +11,25 @@ import java.util.List;
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
public class BeanQueryAdapterManager {
|
||||
class BeanQueryAdapterManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BeanQueryAdapterManager.class);
|
||||
|
||||
private final List<BeanQueryAdapter> list;
|
||||
|
||||
public BeanQueryAdapterManager(BootupClasses bootupClasses) {
|
||||
BeanQueryAdapterManager(BootupClasses bootupClasses) {
|
||||
|
||||
list = bootupClasses.getBeanQueryAdapters();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanPersistController for a given entity type.
|
||||
*/
|
||||
public void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
|
||||
void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
|
||||
|
||||
for (BeanQueryAdapter c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
|
||||
*/
|
||||
public ChainedBeanPersistController(List<BeanPersistController> list) {
|
||||
this.list = list;
|
||||
BeanPersistController[] c = list.toArray(new BeanPersistController[list.size()]);
|
||||
BeanPersistController[] c = list.toArray(new BeanPersistController[0]);
|
||||
Arrays.sort(c, SORTER);
|
||||
this.chain = c;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
|
||||
|
||||
int i1 = o1.getExecutionOrder();
|
||||
int i2 = o2.getExecutionOrder();
|
||||
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
|
||||
return Integer.compare(i1, i2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener {
|
||||
*/
|
||||
public ChainedBeanPersistListener(List<BeanPersistListener> list) {
|
||||
this.list = list;
|
||||
this.chain = list.toArray(new BeanPersistListener[list.size()]);
|
||||
this.chain = list.toArray(new BeanPersistListener[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen
|
||||
*/
|
||||
public ChainedBeanPostConstructListener(List<BeanPostConstructListener> list) {
|
||||
this.list = list;
|
||||
this.chain = list.toArray(new BeanPostConstructListener[list.size()]);
|
||||
this.chain = list.toArray(new BeanPostConstructListener[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad {
|
||||
*/
|
||||
public ChainedBeanPostLoad(List<BeanPostLoad> list) {
|
||||
this.list = list;
|
||||
this.chain = list.toArray(new BeanPostLoad[list.size()]);
|
||||
this.chain = list.toArray(new BeanPostLoad[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter {
|
||||
*/
|
||||
public ChainedBeanQueryAdapter(List<BeanQueryAdapter> list) {
|
||||
this.list = list;
|
||||
BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[list.size()]);
|
||||
BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[0]);
|
||||
Arrays.sort(c, SORTER);
|
||||
this.chain = c;
|
||||
}
|
||||
@@ -89,10 +89,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter {
|
||||
|
||||
@Override
|
||||
public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) {
|
||||
|
||||
int i1 = o1.getExecutionOrder();
|
||||
int i2 = o2.getExecutionOrder();
|
||||
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
|
||||
return Integer.compare(o1.getExecutionOrder(), o2.getExecutionOrder());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.ebeaninternal.api.SpiCacheRegion;
|
||||
|
||||
class DCacheRegionNone implements SpiCacheRegion {
|
||||
|
||||
static SpiCacheRegion INSTANCE = new DCacheRegionNone();
|
||||
static final SpiCacheRegion INSTANCE = new DCacheRegionNone();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@@ -32,11 +32,6 @@ public interface DbSqlContext {
|
||||
*/
|
||||
BeanProperty[] getEncryptedProps();
|
||||
|
||||
/**
|
||||
* Append a char directly to the SQL buffer.
|
||||
*/
|
||||
DbSqlContext append(char s);
|
||||
|
||||
/**
|
||||
* Append a string directly to the SQL buffer.
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyOptions;
|
||||
*/
|
||||
public class DeployDocPropertyOptions {
|
||||
|
||||
private static DocPropertyOptions EMPTY = new DocPropertyOptions();
|
||||
private static final DocPropertyOptions EMPTY = new DocPropertyOptions();
|
||||
|
||||
private DocPropertyOptions mapping;
|
||||
|
||||
|
||||
@@ -10,45 +10,45 @@ public abstract class DeployParser {
|
||||
/**
|
||||
* used to identify sql literal.
|
||||
*/
|
||||
protected static final char SINGLE_QUOTE = '\'';
|
||||
private static final char SINGLE_QUOTE = '\'';
|
||||
|
||||
/**
|
||||
* used to identify query named parameters.
|
||||
*/
|
||||
protected static final char COLON = ':';
|
||||
private static final char COLON = ':';
|
||||
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char UNDERSCORE = '_';
|
||||
private static final char UNDERSCORE = '_';
|
||||
|
||||
protected static final char OPEN_SQUARE_BRACKET = '[';
|
||||
protected static final char CLOSE_SQUARE_BRACKET = ']';
|
||||
protected static final char DOUBLE_QUOTE = '\"';
|
||||
protected static final char BACK_QUOTE = '`';
|
||||
private static final char OPEN_SQUARE_BRACKET = '[';
|
||||
private static final char CLOSE_SQUARE_BRACKET = ']';
|
||||
private static final char DOUBLE_QUOTE = '\"';
|
||||
private static final char BACK_QUOTE = '`';
|
||||
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char PERIOD = '.';
|
||||
private static final char PERIOD = '.';
|
||||
|
||||
protected static final char OPEN_BRACKET = '(';
|
||||
private static final char OPEN_BRACKET = '(';
|
||||
|
||||
protected boolean encrypted;
|
||||
boolean encrypted;
|
||||
|
||||
protected String source;
|
||||
private String source;
|
||||
|
||||
protected StringBuilder sb;
|
||||
private StringBuilder sb;
|
||||
|
||||
protected int sourceLength;
|
||||
private int sourceLength;
|
||||
|
||||
protected int pos;
|
||||
private int pos;
|
||||
|
||||
protected String priorWord;
|
||||
String priorWord;
|
||||
|
||||
protected String word;
|
||||
String word;
|
||||
|
||||
protected char wordTerminator;
|
||||
private char wordTerminator;
|
||||
|
||||
private StringBuilder wordBuffer;
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class DeployParser {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected boolean skipWordConvert() {
|
||||
boolean skipWordConvert() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,7 @@ public class DeployPropertyParserMap extends DeployParser {
|
||||
|
||||
@Override
|
||||
public String getDeployWord(String expression) {
|
||||
|
||||
String deployExpr = map.get(expression);
|
||||
if (deployExpr == null) {
|
||||
return null;
|
||||
} else {
|
||||
return deployExpr;
|
||||
}
|
||||
return map.get(expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,17 +27,19 @@ public final class DeployUpdateParser extends DeployParser {
|
||||
public String convertWord() {
|
||||
|
||||
String dbWord = getDeployWord(word);
|
||||
|
||||
if (dbWord != null) {
|
||||
return dbWord;
|
||||
}
|
||||
// maybe tableAlias.propertyName
|
||||
return convertSubword(0, word, null);
|
||||
return convertSubword(word);
|
||||
}
|
||||
|
||||
private String convertSubword(int start, String currentWord, StringBuilder localBuffer) {
|
||||
while (true) {
|
||||
private String convertSubword(String currentWord) {
|
||||
|
||||
int start = 0;
|
||||
StringBuilder localBuffer = null;
|
||||
|
||||
while (true) {
|
||||
int dotPos = currentWord.indexOf('.', start);
|
||||
if (start == 0 && dotPos == -1) {
|
||||
return currentWord;
|
||||
@@ -52,7 +54,7 @@ public final class DeployUpdateParser extends DeployParser {
|
||||
}
|
||||
|
||||
// append up to the dot
|
||||
localBuffer.append(currentWord.substring(start, dotPos + 1));
|
||||
localBuffer.append(currentWord, start, dotPos + 1);
|
||||
|
||||
if (dotPos == currentWord.length() - 1) {
|
||||
// ends with a "." ???
|
||||
@@ -61,17 +63,13 @@ public final class DeployUpdateParser extends DeployParser {
|
||||
|
||||
// get the remainder after the dot
|
||||
start = dotPos + 1;
|
||||
String remainder = currentWord.substring(start, currentWord.length());
|
||||
String remainder = currentWord.substring(start);
|
||||
|
||||
//String dbWord = deployMap.get(remainder.toLowerCase());
|
||||
String dbWord = getDeployWord(remainder);
|
||||
if (dbWord != null) {
|
||||
// we have found a match for the remainder
|
||||
localBuffer.append(dbWord);
|
||||
return localBuffer.toString();
|
||||
} else {
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,11 +82,7 @@ public final class DeployUpdateParser extends DeployParser {
|
||||
}
|
||||
|
||||
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
|
||||
if (elProp != null) {
|
||||
return elProp.getDbColumn();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return elProp != null ? elProp.getDbColumn() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class DetermineAggPath {
|
||||
// a top level aggregation (so here we need to exclude Id property)
|
||||
return null;
|
||||
}
|
||||
return path.getManyPath(0, desc);
|
||||
return path.getManyPath(desc);
|
||||
}
|
||||
|
||||
static Path paths(String aggregation) {
|
||||
@@ -82,9 +82,9 @@ class DetermineAggPath {
|
||||
}
|
||||
}
|
||||
|
||||
String getManyPath(int pos, DeployBeanDescriptor<?> desc) {
|
||||
String getManyPath(DeployBeanDescriptor<?> desc) {
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
|
||||
String path = paths[pos];
|
||||
DeployBeanProperty details = desc.getBeanProperty(path);
|
||||
if (details instanceof DeployBeanPropertyAssocMany<?>) {
|
||||
@@ -92,8 +92,7 @@ class DetermineAggPath {
|
||||
|
||||
} else if (details instanceof DeployBeanPropertyAssocOne<?>) {
|
||||
DeployBeanPropertyAssocOne<?> one = (DeployBeanPropertyAssocOne<?>) details;
|
||||
DeployBeanDescriptor<?> targetDesc = one.getTargetDeploy();
|
||||
desc = targetDesc;
|
||||
desc = one.getTargetDeploy();
|
||||
pos = pos + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.ebeaninternal.server.type.DataReader;
|
||||
import io.ebeaninternal.server.type.ScalarType;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Dynamic property based on aggregation (max, min, avg, count).
|
||||
@@ -16,7 +15,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
|
||||
|
||||
private final boolean aggregate;
|
||||
|
||||
private final BeanProperty asTarget;
|
||||
final BeanProperty asTarget;
|
||||
|
||||
private final String alias;
|
||||
|
||||
@@ -39,7 +38,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(DataReader dataReader) throws SQLException {
|
||||
public Object read(DataReader dataReader) {
|
||||
try {
|
||||
return scalarType.read(dataReader);
|
||||
} catch (Exception e) {
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebeaninternal.server.query.SqlBeanLoad;
|
||||
|
||||
public class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyAggregationFormula {
|
||||
|
||||
private final BeanPropertyAssocOne prop;
|
||||
|
||||
DynamicPropertyAggregationFormulaMTO(BeanPropertyAssocOne prop, String name, String parsedFormula, boolean aggregate, BeanProperty asTarget, String alias) {
|
||||
super(name, prop.getIdScalarType(), parsedFormula, aggregate, asTarget, alias);
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggregationManyToOne() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(SqlBeanLoad sqlBeanLoad) {
|
||||
Object value;
|
||||
try {
|
||||
value = prop.read(sqlBeanLoad.ctx());
|
||||
} catch (Exception e) {
|
||||
sqlBeanLoad.ctx().handleLoadError(fullName, e);
|
||||
return;
|
||||
}
|
||||
if (asTarget != null) {
|
||||
sqlBeanLoad.load(asTarget, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,9 +11,9 @@ import java.util.List;
|
||||
*/
|
||||
abstract class DynamicPropertyBase implements STreeProperty {
|
||||
|
||||
final String name;
|
||||
private final String name;
|
||||
final String fullName;
|
||||
final String elPrefix;
|
||||
private final String elPrefix;
|
||||
final ScalarType<?> scalarType;
|
||||
|
||||
DynamicPropertyBase(String name, String fullName, String elPrefix, ScalarType<?> scalarType) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class ElementEntityBean implements EntityBean {
|
||||
|
||||
private Object[] data;
|
||||
|
||||
private EntityBeanIntercept intercept;
|
||||
private final EntityBeanIntercept intercept;
|
||||
|
||||
ElementEntityBean(String[] properties) {
|
||||
this.properties = properties;
|
||||
|
||||
@@ -15,7 +15,7 @@ class ElementHelpList implements ElementHelp {
|
||||
|
||||
private static class Collector implements ElementCollector {
|
||||
|
||||
private List<Object> list = new ArrayList<>();
|
||||
private final List<Object> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addElement(Object element) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class ElementHelpMap implements ElementHelp {
|
||||
|
||||
private static class Collector implements ElementCollector {
|
||||
|
||||
private Map<Object, Object> map = new LinkedHashMap<>();
|
||||
private final Map<Object, Object> map = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
public void addElement(Object element) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class ElementHelpSet implements ElementHelp {
|
||||
|
||||
private static class Collector implements ElementCollector {
|
||||
|
||||
private Set<Object> set = new LinkedHashSet<>();
|
||||
private final Set<Object> set = new LinkedHashSet<>();
|
||||
|
||||
@Override
|
||||
public void addElement(Object element) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.core.InternString;
|
||||
* Used to for Assoc Manys to create references etc.
|
||||
* </p>
|
||||
*/
|
||||
public class ExportedProperty {
|
||||
class ExportedProperty {
|
||||
|
||||
private final String foreignDbColumn;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ExportedProperty {
|
||||
|
||||
private final boolean embedded;
|
||||
|
||||
public ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
|
||||
ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
|
||||
this.embedded = embedded;
|
||||
this.foreignDbColumn = InternString.intern(foreignDbColumn);
|
||||
this.property = property;
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.type.ScalarType;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
class FormulaPropertyPath {
|
||||
final class FormulaPropertyPath {
|
||||
|
||||
private static final String[] AGG_FUNCTIONS = {"count", "max", "min", "avg", "sum"};
|
||||
|
||||
@@ -20,17 +20,22 @@ class FormulaPropertyPath {
|
||||
|
||||
private final String internalExpression;
|
||||
|
||||
private final String path;
|
||||
private final ElPropertyDeploy firstProp;
|
||||
|
||||
private final String parsedAggregation;
|
||||
|
||||
private boolean countDistinct;
|
||||
|
||||
private String cast;
|
||||
private String alias;
|
||||
|
||||
static STreeProperty create(BeanDescriptor<?> descriptor, String formula, String path) {
|
||||
return new FormulaPropertyPath(descriptor, formula, path).build();
|
||||
}
|
||||
|
||||
FormulaPropertyPath(BeanDescriptor<?> descriptor, String formula, String path) {
|
||||
this.descriptor = descriptor;
|
||||
this.formula = formula;
|
||||
this.path = path;
|
||||
|
||||
int openBracket = formula.indexOf('(');
|
||||
int closeBracket = formula.lastIndexOf(')');
|
||||
@@ -38,13 +43,21 @@ class FormulaPropertyPath {
|
||||
throw new IllegalStateException("Unable to parse formula [" + formula + "]");
|
||||
}
|
||||
outerFunction = formula.substring(0, openBracket).trim();
|
||||
internalExpression = trimDistinct(formula.substring(openBracket+1, closeBracket));
|
||||
internalExpression = trimDistinct(formula.substring(openBracket + 1, closeBracket));
|
||||
|
||||
if (closeBracket < formula.length() -1) {
|
||||
if (closeBracket < formula.length() - 1) {
|
||||
// ::CastType as foo
|
||||
String suffix = formula.substring(closeBracket+1).trim();
|
||||
parseSuffix(suffix);
|
||||
parseSuffix(formula.substring(closeBracket + 1).trim());
|
||||
}
|
||||
|
||||
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
|
||||
String parsed = parser.parse(internalExpression);
|
||||
if (path != null) {
|
||||
// fetch("machineStats", "sum(hours), sum(totalKms)")
|
||||
parsed = parsed.replace("${}", "${" + path + "}");
|
||||
}
|
||||
this.parsedAggregation = buildFormula(parsed);
|
||||
this.firstProp = parser.getFirstProp();
|
||||
}
|
||||
|
||||
private void parseSuffix(String suffix) {
|
||||
@@ -93,42 +106,50 @@ class FormulaPropertyPath {
|
||||
|
||||
STreeProperty build() {
|
||||
|
||||
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
|
||||
|
||||
String parsed = parser.parse(internalExpression);
|
||||
if (path != null) {
|
||||
// fetch("machineStats", "sum(hours), sum(totalKms)")
|
||||
parsed = parsed.replace("${}", "${" + path + "}");
|
||||
}
|
||||
|
||||
ElPropertyDeploy firstProp = parser.getFirstProp();
|
||||
|
||||
ScalarType<?> scalarType;
|
||||
if (cast != null) {
|
||||
scalarType = descriptor.getScalarType(cast);
|
||||
ScalarType<?> scalarType = descriptor.getScalarType(cast);
|
||||
if (scalarType == null) {
|
||||
throw new IllegalStateException("Unable to find scalarType for cast of ["+cast+"] on formula [" + formula + "] for type " + descriptor);
|
||||
}
|
||||
|
||||
} else if (isCount()) {
|
||||
scalarType = descriptor.getScalarType(Types.BIGINT);
|
||||
|
||||
} else if (isConcat()) {
|
||||
scalarType = descriptor.getScalarType(Types.VARCHAR);
|
||||
|
||||
} else {
|
||||
// determine scalarType based on first property found by parser
|
||||
if (firstProp != null) {
|
||||
scalarType = firstProp.getBeanProperty().getScalarType();
|
||||
} else {
|
||||
throw new IllegalStateException("unable to determine scalarType of formula [" + formula + "] for type " + descriptor + " - maybe use a cast like ::String ?");
|
||||
throw new IllegalStateException("Unable to find scalarType for cast of [" + cast + "] on formula [" + formula + "] for type " + descriptor);
|
||||
}
|
||||
return create(scalarType);
|
||||
}
|
||||
if (isCount()) {
|
||||
return create(descriptor.getScalarType(Types.BIGINT));
|
||||
}
|
||||
if (isConcat()) {
|
||||
return create(descriptor.getScalarType(Types.VARCHAR));
|
||||
}
|
||||
if (firstProp == null) {
|
||||
throw new IllegalStateException("unable to determine scalarType of formula [" + formula + "] for type " + descriptor + " - maybe use a cast like ::String ?");
|
||||
}
|
||||
|
||||
String logicalName = (alias == null) ? internalExpression : alias;
|
||||
BeanProperty targetProperty = descriptor._findBeanProperty(logicalName);
|
||||
String parsedAggregation = buildFormula(parsed);
|
||||
return new DynamicPropertyAggregationFormula(logicalName, scalarType, parsedAggregation, isAggregate(), targetProperty, alias);
|
||||
// determine scalarType based on first property found by parser
|
||||
final BeanProperty property = firstProp.getBeanProperty();
|
||||
if (!property.isAssocId()) {
|
||||
return create(property.getScalarType());
|
||||
} else {
|
||||
return createManyToOne(property);
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicPropertyAggregationFormula create(ScalarType<?> scalarType) {
|
||||
|
||||
String logicalName = logicalName();
|
||||
return new DynamicPropertyAggregationFormula(logicalName, scalarType, parsedAggregation, isAggregate(), target(logicalName), alias);
|
||||
}
|
||||
|
||||
private DynamicPropertyAggregationFormula createManyToOne(BeanProperty property) {
|
||||
|
||||
String logicalName = logicalName();
|
||||
return new DynamicPropertyAggregationFormulaMTO((BeanPropertyAssocOne) property, logicalName, parsedAggregation, isAggregate(), target(logicalName), alias);
|
||||
}
|
||||
|
||||
private BeanProperty target(String logicalName) {
|
||||
return descriptor._findBeanProperty(logicalName);
|
||||
}
|
||||
|
||||
private String logicalName() {
|
||||
return (alias == null) ? internalExpression : alias;
|
||||
}
|
||||
|
||||
private boolean isAggregate() {
|
||||
|
||||
@@ -11,15 +11,6 @@ public class IndexDefinition {
|
||||
|
||||
private final boolean unique;
|
||||
|
||||
/**
|
||||
* A single column index.
|
||||
*/
|
||||
public IndexDefinition(String column, String name, boolean unique) {
|
||||
this.columns = new String[]{column};
|
||||
this.unique = unique;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public IndexDefinition(String[] columns, String name, boolean unique) {
|
||||
this.columns = columns;
|
||||
this.unique = unique;
|
||||
|
||||
@@ -6,11 +6,12 @@ import io.ebeaninternal.server.deploy.id.IdBinder;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployInheritInfo;
|
||||
import io.ebeaninternal.server.query.SqlTreeProperties;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ public class InheritInfo {
|
||||
|
||||
private final Class<?> type;
|
||||
|
||||
private final ArrayList<InheritInfo> children = new ArrayList<>();
|
||||
private final List<InheritInfo> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Map of discriminator values to InheritInfo.
|
||||
@@ -111,7 +112,7 @@ public class InheritInfo {
|
||||
* return true if anything in the inheritance hierarchy has a relationship with a save cascade on
|
||||
* it.
|
||||
*/
|
||||
public boolean isSaveRecurseSkippable() {
|
||||
boolean isSaveRecurseSkippable() {
|
||||
return root.isNodeSaveRecurseSkippable();
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ public class InheritInfo {
|
||||
* return true if anything in the inheritance hierarchy has a relationship with a delete cascade
|
||||
* on it.
|
||||
*/
|
||||
public boolean isDeleteRecurseSkippable() {
|
||||
boolean isDeleteRecurseSkippable() {
|
||||
return root.isNodeDeleteRecurseSkippable();
|
||||
}
|
||||
|
||||
@@ -171,14 +172,24 @@ public class InheritInfo {
|
||||
/**
|
||||
* Return the children.
|
||||
*/
|
||||
public ArrayList<InheritInfo> getChildren() {
|
||||
public List<InheritInfo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this node has children.
|
||||
* <p>
|
||||
* When an inheritance node has no children then we don't need
|
||||
* the discriminator column as the type is effectively known.
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return !children.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bean property additionally looking in the sub types.
|
||||
*/
|
||||
public BeanProperty findSubTypeProperty(String propertyName) {
|
||||
BeanProperty findSubTypeProperty(String propertyName) {
|
||||
|
||||
BeanProperty prop;
|
||||
|
||||
@@ -200,7 +211,6 @@ public class InheritInfo {
|
||||
|
||||
for (InheritInfo childInfo : children) {
|
||||
selectProps.add(childInfo.descriptor.propertiesLocal());
|
||||
|
||||
childInfo.addChildrenProperties(selectProps);
|
||||
}
|
||||
}
|
||||
@@ -209,15 +219,16 @@ public class InheritInfo {
|
||||
* Return the associated InheritInfo for this DB row read.
|
||||
*/
|
||||
public InheritInfo readType(DbReadContext ctx) throws SQLException {
|
||||
|
||||
String discValue = ctx.getDataReader().getString();
|
||||
return readType(discValue);
|
||||
if (!hasChildren()) {
|
||||
return this;
|
||||
}
|
||||
return readType(ctx.getDataReader().getString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the associated InheritInfo for this discriminator value.
|
||||
*/
|
||||
public InheritInfo readType(String discValue) {
|
||||
InheritInfo readType(String discValue) {
|
||||
|
||||
if (discValue == null) {
|
||||
return null;
|
||||
@@ -327,7 +338,6 @@ public class InheritInfo {
|
||||
* Return the derived where for the discriminator.
|
||||
*/
|
||||
public String getWhere() {
|
||||
|
||||
return where;
|
||||
}
|
||||
|
||||
@@ -362,7 +372,7 @@ public class InheritInfo {
|
||||
/**
|
||||
* Return the discriminator value for this node.
|
||||
*/
|
||||
public String getDiscriminatorStringValue() {
|
||||
String getDiscriminatorStringValue() {
|
||||
return discriminatorStringValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Helper object to find generic parameter types for a given class.
|
||||
*/
|
||||
public class ParamTypeUtil {
|
||||
|
||||
/**
|
||||
* Find and return the parameter type given a generic interface or class.
|
||||
* <p>
|
||||
* This assumes there is only one generic parameter.
|
||||
* </p>
|
||||
* <p>
|
||||
* Returns null if no match was found.
|
||||
* </p>
|
||||
*
|
||||
* @param cls the class to search for the parameter type
|
||||
* @param matchType the type which has the generic parameter
|
||||
*/
|
||||
public static Class<?> findParamType(Class<?> cls, Class<?> matchType) {
|
||||
|
||||
// search for: implementing a generic interface
|
||||
Type paramType = matchByInterfaces(cls, matchType);
|
||||
if (paramType == null) {
|
||||
// search for: extending a generic class
|
||||
Type genericSuperclass = cls.getGenericSuperclass();
|
||||
if (genericSuperclass != null) {
|
||||
paramType = matchParamType(genericSuperclass, matchType);
|
||||
}
|
||||
}
|
||||
|
||||
if (paramType instanceof Class<?>) {
|
||||
// only interested in classes
|
||||
return (Class<?>) paramType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the type is a generic one with parameters and of the correct type we are
|
||||
* searching for. Return the parameter type if this matches otherwise return null.
|
||||
*/
|
||||
private static Type matchParamType(Type type, Class<?> matchType) {
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType pt = (ParameterizedType) type;
|
||||
Type rawType = pt.getRawType();
|
||||
boolean isAssignable = matchType.isAssignableFrom((Class<?>) rawType);
|
||||
if (isAssignable) {
|
||||
// assume there is only one parameter type
|
||||
Type[] typeArguments = pt.getActualTypeArguments();
|
||||
if (typeArguments.length != 1) {
|
||||
String m = "Expecting only 1 generic paramater but got " + typeArguments.length + " for " + type;
|
||||
throw new RuntimeException(m);
|
||||
}
|
||||
return typeArguments[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the interfaces this class implements.
|
||||
*/
|
||||
private static Type matchByInterfaces(Class<?> cls, Class<?> matchType) {
|
||||
|
||||
Type[] gis = cls.getGenericInterfaces();
|
||||
for (Type gi : gis) {
|
||||
Type match = matchParamType(gi, matchType);
|
||||
if (match != null) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,25 +11,25 @@ import java.util.List;
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
public class PersistControllerManager {
|
||||
class PersistControllerManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PersistControllerManager.class);
|
||||
|
||||
private final List<BeanPersistController> list;
|
||||
|
||||
public PersistControllerManager(BootupClasses bootupClasses) {
|
||||
PersistControllerManager(BootupClasses bootupClasses) {
|
||||
|
||||
list = bootupClasses.getBeanPersistControllers();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanPersistController for a given entity type.
|
||||
*/
|
||||
public void addPersistControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
void addPersistControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
|
||||
for (BeanPersistController c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
|
||||
@@ -12,24 +12,24 @@ import java.util.List;
|
||||
* Manages the assignment/registration of BeanPersistListener with their
|
||||
* respective DeployBeanDescriptor's.
|
||||
*/
|
||||
public class PersistListenerManager {
|
||||
class PersistListenerManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PersistListenerManager.class);
|
||||
|
||||
private final List<BeanPersistListener> list;
|
||||
|
||||
public PersistListenerManager(BootupClasses bootupClasses) {
|
||||
PersistListenerManager(BootupClasses bootupClasses) {
|
||||
list = bootupClasses.getBeanPersistListeners();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanPersistController for a given entity type.
|
||||
*/
|
||||
public <T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||
<T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||
|
||||
for (BeanPersistListener listener : list) {
|
||||
if (listener.isRegisterFor(deployDesc.getBeanType())) {
|
||||
|
||||
@@ -11,24 +11,24 @@ import java.util.List;
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
public class PostConstructManager {
|
||||
class PostConstructManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PostConstructManager.class);
|
||||
|
||||
private final List<BeanPostConstructListener> list;
|
||||
|
||||
public PostConstructManager(BootupClasses bootupClasses) {
|
||||
PostConstructManager(BootupClasses bootupClasses) {
|
||||
this.list = bootupClasses.getBeanPostConstructoListeners();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register BeanPostLoad listeners for a given entity type.
|
||||
*/
|
||||
public void addPostConstructListeners(DeployBeanDescriptor<?> deployDesc) {
|
||||
void addPostConstructListeners(DeployBeanDescriptor<?> deployDesc) {
|
||||
|
||||
for (BeanPostConstructListener c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
|
||||
@@ -11,24 +11,24 @@ import java.util.List;
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
public class PostLoadManager {
|
||||
class PostLoadManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PostLoadManager.class);
|
||||
|
||||
private final List<BeanPostLoad> list;
|
||||
|
||||
public PostLoadManager(BootupClasses bootupClasses) {
|
||||
PostLoadManager(BootupClasses bootupClasses) {
|
||||
this.list = bootupClasses.getBeanPostLoaders();
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
int getRegisterCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register BeanPostLoad listeners for a given entity type.
|
||||
*/
|
||||
public void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
|
||||
void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
|
||||
|
||||
for (BeanPostLoad c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
|
||||
@@ -33,11 +33,17 @@ public final class TableJoin {
|
||||
*/
|
||||
private final int queryHash;
|
||||
|
||||
private final PropertyForeignKey foreignKey;
|
||||
|
||||
public TableJoin(DeployTableJoin deploy) {
|
||||
this(deploy, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TableJoin.
|
||||
*/
|
||||
public TableJoin(DeployTableJoin deploy) {
|
||||
|
||||
public TableJoin(DeployTableJoin deploy, PropertyForeignKey foreignKey) {
|
||||
this.foreignKey = foreignKey;
|
||||
this.table = InternString.intern(deploy.getTable());
|
||||
this.type = deploy.getType();
|
||||
this.inheritInfo = deploy.getInheritInfo();
|
||||
@@ -52,6 +58,7 @@ public final class TableJoin {
|
||||
}
|
||||
|
||||
private TableJoin(TableJoin source, String overrideColumn) {
|
||||
this.foreignKey = null;
|
||||
this.table = source.table;
|
||||
this.type = source.type;
|
||||
this.inheritInfo = source.inheritInfo;
|
||||
@@ -96,14 +103,6 @@ public final class TableJoin {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a hash value for adding to a query plan.
|
||||
*/
|
||||
public int queryHash() {
|
||||
return queryHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(30);
|
||||
@@ -114,6 +113,13 @@ public final class TableJoin {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the foreign key options.
|
||||
*/
|
||||
public PropertyForeignKey getForeignKey() {
|
||||
return foreignKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the join columns.
|
||||
*/
|
||||
@@ -128,21 +134,13 @@ public final class TableJoin {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of join. LEFT JOIN etc.
|
||||
*/
|
||||
public SqlJoinType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx, String predicate) {
|
||||
public void addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx, String predicate) {
|
||||
String[] names = SplitName.split(prefix);
|
||||
String a1 = ctx.getTableAlias(names[0]);
|
||||
String a2 = ctx.getTableAlias(prefix);
|
||||
|
||||
SqlJoinType returnJoinType = addJoin(joinType, a1, a2, ctx);
|
||||
addJoin(joinType, a1, a2, ctx);
|
||||
ctx.append("and ").append(a2).append(predicate);
|
||||
return returnJoinType;
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TableJoinColumn {
|
||||
this.queryHash = hash();
|
||||
}
|
||||
|
||||
int hash() {
|
||||
private int hash() {
|
||||
int result = localDbColumn != null ? localDbColumn.hashCode() : 0;
|
||||
result = 92821 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0);
|
||||
result = 92821 * result + (localSqlFormula != null ? localSqlFormula.hashCode() : 0);
|
||||
@@ -93,7 +93,7 @@ public class TableJoinColumn {
|
||||
/**
|
||||
* Return a hash for including in a query plan.
|
||||
*/
|
||||
public int queryHash() {
|
||||
int queryHash() {
|
||||
return queryHash;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class TableJoinColumn {
|
||||
/**
|
||||
* Return true if this column should be updateable.
|
||||
*/
|
||||
public boolean isUpdateable() {
|
||||
boolean isUpdateable() {
|
||||
return updateable;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ import java.sql.Types;
|
||||
* Aka, Integer, Long, Short etc.
|
||||
* </p>
|
||||
*/
|
||||
public class CounterFactory {
|
||||
class CounterFactory {
|
||||
|
||||
final GeneratedCounterInteger integerCounter = new GeneratedCounterInteger();
|
||||
private final GeneratedCounterInteger integerCounter = new GeneratedCounterInteger();
|
||||
|
||||
final GeneratedCounterLong longCounter = new GeneratedCounterLong();
|
||||
private final GeneratedCounterLong longCounter = new GeneratedCounterLong();
|
||||
|
||||
public void setCounter(DeployBeanProperty property) {
|
||||
|
||||
|
||||
+2
-2
@@ -9,9 +9,9 @@ import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
*/
|
||||
public class GeneratedCounter implements GeneratedProperty {
|
||||
|
||||
final int numberType;
|
||||
private final int numberType;
|
||||
|
||||
public GeneratedCounter(int numberType) {
|
||||
GeneratedCounter(int numberType) {
|
||||
this.numberType = numberType;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user