mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge remote-tracking branch 'upstream/master' into issue-2774/encryption-support-for-in
This commit is contained in:
commit
3a2b20eb43
794 files changed
+5256
-4799
No files matched your search
+13
-14
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core</artifactId>
|
||||
@@ -19,6 +19,11 @@
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
@@ -38,22 +43,16 @@
|
||||
<version>${ebean-migration-auto.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-api</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -106,7 +105,7 @@
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.7</version>
|
||||
<version>2.11.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -136,7 +135,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.4.1</version>
|
||||
<version>42.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -144,21 +143,21 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-sqlserver</artifactId>
|
||||
<version>13.7.1-SNAPSHOT</version>
|
||||
<version>13.10.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -228,10 +228,9 @@ public final class BindParams implements Serializable {
|
||||
/**
|
||||
* Set a named In parameter that is multi-valued.
|
||||
*/
|
||||
public Param setArrayParameter(String name, Collection<?> value) {
|
||||
public void setArrayParameter(String name, Collection<?> value) {
|
||||
Param p = getParam(name);
|
||||
p.setInValue(new MultiValueWrapper(value));
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ public interface CQueryPlanKey {
|
||||
* Used by read audit such that we can log read audit entries without the full sql
|
||||
* (which would make the read audit logs verbose).
|
||||
*/
|
||||
String getPartialKey();
|
||||
String partialKey();
|
||||
|
||||
/**
|
||||
* Return a query plan key taking into account persist cascading.
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.avaje.applog.AppLog;
|
||||
|
||||
/**
|
||||
* Common loggers used in ebean-core.
|
||||
*/
|
||||
public final class CoreLog {
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger("io.ebean.core");
|
||||
public static final Logger internal = LoggerFactory.getLogger("io.ebean.internal");
|
||||
public static final System.Logger log = AppLog.getLogger("io.ebean.core");
|
||||
public static final System.Logger internal = AppLog.getLogger("io.ebean.internal");
|
||||
}
|
||||
@@ -7,17 +7,18 @@ import io.ebeaninternal.server.core.BindPadding;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Request for loading Associated Many Beans.
|
||||
*/
|
||||
public final class LoadManyRequest extends LoadRequest {
|
||||
|
||||
private static final Logger log = CoreLog.log;
|
||||
private static final System.Logger log = CoreLog.log;
|
||||
|
||||
private final List<BeanCollection<?>> batch;
|
||||
private final LoadManyBuffer loadContext;
|
||||
@@ -113,10 +114,10 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
// in the +query or +lazy load due to no rows (predicates)
|
||||
for (BeanCollection<?> bc : batch) {
|
||||
if (bc.checkEmptyLazyLoad()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
if (log.isLoggable(DEBUG)) {
|
||||
EntityBean ownerBean = bc.getOwnerBean();
|
||||
Object parentId = desc.getId(ownerBean);
|
||||
log.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
||||
log.log(DEBUG, "BeanCollection after lazy load was empty. type:{0} id:{1} owner:{2}", ownerBean.getClass().getName(), parentId, ownerBean);
|
||||
}
|
||||
} else if (loadCache && many.isUseCache()) {
|
||||
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
|
||||
|
||||
@@ -50,7 +50,6 @@ public final class ManyWhereJoins implements Serializable {
|
||||
* Add a many where join.
|
||||
*/
|
||||
public void add(ElPropertyDeploy elProp) {
|
||||
|
||||
String join = elProp.elPrefix();
|
||||
BeanProperty p = elProp.beanProperty();
|
||||
if (p instanceof BeanPropertyAssocMany<?>) {
|
||||
@@ -111,7 +110,6 @@ public final class ManyWhereJoins implements Serializable {
|
||||
* Return the set of property names for the many where joins.
|
||||
*/
|
||||
public TreeSet<String> getPropertyNames() {
|
||||
|
||||
TreeSet<String> propertyNames = new TreeSet<>();
|
||||
for (PropertyJoin join : joins.values()) {
|
||||
propertyNames.add(join.getProperty());
|
||||
|
||||
@@ -142,7 +142,9 @@ public final class NaturalKeyQueryData<T> {
|
||||
*/
|
||||
private boolean matchProperties() {
|
||||
if (naturalKey.isSingleProperty()) {
|
||||
naturalKey.matchSingleProperty((inProperty != null) ? inProperty : eqList.get(0).property);
|
||||
if (naturalKey.matchSingleProperty((inProperty != null) ? inProperty : eqList.get(0).property)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// multiple properties case
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
import io.ebeaninternal.server.bind.capture.BindCapture;
|
||||
|
||||
final class NoopQueryBindCapture implements SpiQueryBindCapture {
|
||||
|
||||
|
||||
@@ -45,15 +45,14 @@ public final class ScopeTrans {
|
||||
* Flag set when nested commit has occurred.
|
||||
*/
|
||||
private boolean nestedCommit;
|
||||
private boolean nestedUseSavepoint;
|
||||
|
||||
public ScopeTrans(boolean rollbackOnChecked, boolean created, SpiTransaction transaction, TxScope txScope) {
|
||||
|
||||
this.rollbackOnChecked = rollbackOnChecked;
|
||||
this.created = created;
|
||||
this.transaction = transaction;
|
||||
this.noRollbackFor = txScope.getNoRollbackFor();
|
||||
this.rollbackFor = txScope.getRollbackFor();
|
||||
|
||||
if (transaction != null) {
|
||||
if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) {
|
||||
restoreBatch = transaction.isBatchMode();
|
||||
@@ -87,13 +86,21 @@ public final class ScopeTrans {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScopeTrans[" + transaction + "]";
|
||||
return "ScopeTrans " + transaction;
|
||||
}
|
||||
|
||||
void setNestedUseSavepoint() {
|
||||
nestedUseSavepoint = true;
|
||||
}
|
||||
|
||||
boolean isNestedUseSavepoint() {
|
||||
return nestedUseSavepoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current/active transaction.
|
||||
*/
|
||||
protected SpiTransaction getTransaction() {
|
||||
SpiTransaction getTransaction() {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
@@ -101,7 +108,6 @@ public final class ScopeTrans {
|
||||
* Complete the transaction from enhanced transactional. Try to commit.
|
||||
*/
|
||||
void complete(Object returnOrThrowable, int opCode) {
|
||||
|
||||
if (opCode == OPCODE_ATHROW) {
|
||||
// exited with a Throwable
|
||||
caughtThrowable((Throwable) returnOrThrowable);
|
||||
@@ -124,7 +130,7 @@ public final class ScopeTrans {
|
||||
}
|
||||
}
|
||||
|
||||
protected void commitTransaction() {
|
||||
void commitTransaction() {
|
||||
if (created) {
|
||||
transaction.commit();
|
||||
} else {
|
||||
@@ -168,14 +174,13 @@ public final class ScopeTrans {
|
||||
* Returns the exception and this should be thrown by the calling code.
|
||||
*/
|
||||
public <T extends Throwable> T caughtThrowable(T e) {
|
||||
|
||||
if (isRollbackThrowable(e)) {
|
||||
rollback(e);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
protected void rollback(Throwable e) {
|
||||
void rollback(Throwable e) {
|
||||
if (transaction != null && transaction.isActive()) {
|
||||
// transaction is null for NOT_SUPPORTED and sometimes SUPPORTS
|
||||
// and Inactive (already rolled back) if nested REQUIRED
|
||||
@@ -188,21 +193,17 @@ public final class ScopeTrans {
|
||||
* Return true if this throwable should cause a rollback to occur.
|
||||
*/
|
||||
private boolean isRollbackThrowable(Throwable e) {
|
||||
|
||||
if (e instanceof Error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (noRollbackFor != null) {
|
||||
for (Class<? extends Throwable> aNoRollbackFor : noRollbackFor) {
|
||||
if (aNoRollbackFor.equals(e.getClass())) {
|
||||
|
||||
// explicit no rollback for this one
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rollbackFor != null) {
|
||||
for (Class<? extends Throwable> aRollbackFor : rollbackFor) {
|
||||
if (aRollbackFor.equals(e.getClass())) {
|
||||
@@ -211,7 +212,6 @@ public final class ScopeTrans {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checked exceptions...
|
||||
// EJB defaults this to false which is not intuitive IMO
|
||||
// Ebean makes this configurable (default to true)
|
||||
|
||||
@@ -7,7 +7,7 @@ import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* Manage scoped (typically thread local) transactions.
|
||||
*
|
||||
* <p>
|
||||
* These can be nested and internally they are pushed and popped from a stack.
|
||||
*/
|
||||
public final class ScopedTransaction extends SpiTransactionProxy {
|
||||
@@ -30,16 +30,29 @@ public final class ScopedTransaction extends SpiTransactionProxy {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScopedTransaction[" + current + "]";
|
||||
return "ScopedTransaction " + current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedUseSavepoint() {
|
||||
current.setNestedUseSavepoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNestedUseSavepoint() {
|
||||
return current.isNestedUseSavepoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the scope transaction.
|
||||
*/
|
||||
public void push(ScopeTrans scopeTrans) {
|
||||
|
||||
if (current != null) {
|
||||
stack.push(current);
|
||||
if (current.isNestedUseSavepoint()) {
|
||||
// child scope 'inherits' nestedUseSavepoint
|
||||
scopeTrans.setNestedUseSavepoint();
|
||||
}
|
||||
}
|
||||
current = scopeTrans;
|
||||
transaction = scopeTrans.getTransaction();
|
||||
@@ -111,6 +124,11 @@ public final class ScopedTransaction extends SpiTransactionProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollbackAndContinue() {
|
||||
transaction.rollbackAndContinue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() throws PersistenceException {
|
||||
try {
|
||||
|
||||
@@ -13,8 +13,8 @@ import java.io.IOException;
|
||||
*/
|
||||
public interface SpiExpression extends Expression {
|
||||
|
||||
static final String SQL_TRUE = "1=1";
|
||||
static final String SQL_FALSE = "1=0";
|
||||
String SQL_TRUE = "1=1";
|
||||
String SQL_FALSE = "1=0";
|
||||
|
||||
/**
|
||||
* Simplify nested expressions if possible.
|
||||
@@ -110,4 +110,11 @@ public interface SpiExpression extends Expression {
|
||||
* Apply property prefix when filterMany expressions included into main query.
|
||||
*/
|
||||
void prefixProperty(String path);
|
||||
|
||||
/**
|
||||
* Return a copy of the expression (as part of creating a query copy).
|
||||
*/
|
||||
default SpiExpression copy() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -314,7 +314,7 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
|
||||
* Return true if select all properties was used to ensure the property
|
||||
* invoking a lazy load was included in the query.
|
||||
*/
|
||||
boolean selectAllForLazyLoadProperty();
|
||||
void selectAllForLazyLoadProperty();
|
||||
|
||||
/**
|
||||
* Set the select properties.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
import io.ebeaninternal.server.bind.capture.BindCapture;
|
||||
|
||||
/**
|
||||
* Capture query bind values and with those actual database query plans.
|
||||
|
||||
@@ -10,27 +10,27 @@ public interface SpiQueryPlan {
|
||||
/**
|
||||
* The related entity bean type
|
||||
*/
|
||||
Class<?> getBeanType();
|
||||
Class<?> beanType();
|
||||
|
||||
/**
|
||||
* The plan name.
|
||||
*/
|
||||
String getName();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The hash of the sql.
|
||||
*/
|
||||
String getHash();
|
||||
String hash();
|
||||
|
||||
/**
|
||||
* The SQL for the query plan.
|
||||
*/
|
||||
String getSql();
|
||||
String sql();
|
||||
|
||||
/**
|
||||
* The related profile location.
|
||||
*/
|
||||
ProfileLocation getProfileLocation();
|
||||
ProfileLocation profileLocation();
|
||||
|
||||
/**
|
||||
* Initiate bind capture with the give threshold.
|
||||
|
||||
@@ -139,7 +139,7 @@ public final class TransactionEvent implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the CacheChangeSet that we add cache notification messages to.
|
||||
*
|
||||
* <p>
|
||||
* We want to add to this change set as we process requests allowing the
|
||||
* PersistRequestBean to be garbage collected for large transactions.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.ebeaninternal.api;
|
||||
|
||||
/**
|
||||
* Event codes used in transaction profiling.
|
||||
*
|
||||
* <p>
|
||||
* These appear in verbose transaction profile logs.
|
||||
*/
|
||||
public interface TxnProfileEventCodes {
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Map;
|
||||
|
||||
public interface SpiJsonReader {
|
||||
|
||||
PersistenceContext getPersistenceContext();
|
||||
PersistenceContext persistenceContext();
|
||||
|
||||
SpiJsonReader forJson(JsonParser moreJson);
|
||||
|
||||
@@ -20,9 +20,9 @@ public interface SpiJsonReader {
|
||||
|
||||
Object persistenceContextPutIfAbsent(Object id, EntityBean bean, BeanDescriptor<?> beanDesc);
|
||||
|
||||
ObjectMapper getObjectMapper();
|
||||
ObjectMapper mapper();
|
||||
|
||||
JsonParser getParser();
|
||||
JsonParser parser();
|
||||
|
||||
JsonToken nextToken() throws IOException;
|
||||
|
||||
@@ -34,5 +34,5 @@ public interface SpiJsonReader {
|
||||
|
||||
Object readValueUsingObjectMapper(Class<?> propertyType) throws IOException;
|
||||
|
||||
boolean isIntercept();
|
||||
boolean intercept();
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public interface SpiJsonWriter extends JsonWriter {
|
||||
/**
|
||||
* Return true if the value is a parent bean.
|
||||
*/
|
||||
boolean isParentBean(Object value);
|
||||
boolean parentBean(Object value);
|
||||
|
||||
/**
|
||||
* Start an assoc one path.
|
||||
|
||||
+6
-13
@@ -1,25 +1,18 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
package io.ebeaninternal.server.bind;
|
||||
|
||||
import io.ebean.core.type.DataBinder;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Array;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
public class DataBind implements DataBinder {
|
||||
|
||||
private final DataTimeZone dataTimeZone;
|
||||
@@ -109,7 +102,7 @@ public class DataBind implements DataBinder {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
CoreLog.log.warn("Error closing InputStream that was bound to PreparedStatement", e);
|
||||
CoreLog.log.log(WARNING, "Error closing InputStream that was bound to PreparedStatement", e);
|
||||
}
|
||||
}
|
||||
inputStreams = null;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
package io.ebeaninternal.server.bind;
|
||||
|
||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCaptureStatement;
|
||||
import io.ebeaninternal.server.bind.capture.BindCapture;
|
||||
import io.ebeaninternal.server.bind.capture.BindCaptureStatement;
|
||||
|
||||
/**
|
||||
* Special DataBind used to capture bind values for obtaining explain plans.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.ebeaninternal.server.type.bindcapture;
|
||||
package io.ebeaninternal.server.bind.capture;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.ebeaninternal.server.type.bindcapture;
|
||||
package io.ebeaninternal.server.bind.capture;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.ebeaninternal.server.type.bindcapture;
|
||||
package io.ebeaninternal.server.bind.capture;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.ebeaninternal.server.type.bindcapture;
|
||||
package io.ebeaninternal.server.bind.capture;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.ebeaninternal.server.type.bindcapture;
|
||||
package io.ebeaninternal.server.bind.capture;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringReader;
|
||||
+8
-6
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.CacheBeanTuning;
|
||||
import io.ebean.annotation.CacheQueryTuning;
|
||||
@@ -7,20 +8,21 @@ import io.ebean.cache.*;
|
||||
import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.util.AnnotationUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.TRACE;
|
||||
|
||||
/**
|
||||
* Manages the construction of caches.
|
||||
*/
|
||||
final class DefaultCacheHolder {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.ALL");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.ALL");
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final ConcurrentHashMap<String, ServerCache> allCaches = new ConcurrentHashMap<>();
|
||||
@@ -89,7 +91,7 @@ final class DefaultCacheHolder {
|
||||
}
|
||||
|
||||
void clearAll() {
|
||||
log.debug("clearAll");
|
||||
log.log(DEBUG, "clearAll");
|
||||
for (ServerCache serverCache : allCaches.values()) {
|
||||
serverCache.clear();
|
||||
}
|
||||
@@ -97,7 +99,7 @@ final class DefaultCacheHolder {
|
||||
|
||||
|
||||
public void clear(String name) {
|
||||
log.debug("clear {}", name);
|
||||
log.log(DEBUG, "clear {0}", name);
|
||||
clearIfExists(key(name, ServerCacheType.QUERY));
|
||||
clearIfExists(key(name, ServerCacheType.BEAN));
|
||||
clearIfExists(key(name, ServerCacheType.NATURAL_KEY));
|
||||
@@ -112,7 +114,7 @@ final class DefaultCacheHolder {
|
||||
private void clearIfExists(String fullKey) {
|
||||
ServerCache cache = allCaches.get(fullKey);
|
||||
if (cache != null) {
|
||||
log.trace("clear cache {}", fullKey);
|
||||
log.log(TRACE, "clear cache {0}", fullKey);
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -1,13 +1,12 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheStatistics;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.metric.CountMetric;
|
||||
import io.ebean.metric.MetricFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.SoftReference;
|
||||
@@ -16,6 +15,9 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static java.lang.System.Logger.Level.TRACE;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
/**
|
||||
* The default cache implementation.
|
||||
* <p>
|
||||
@@ -25,7 +27,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
*/
|
||||
public class DefaultServerCache implements ServerCache {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(DefaultServerCache.class);
|
||||
protected static final System.Logger logger = AppLog.getLogger(DefaultServerCache.class);
|
||||
|
||||
/**
|
||||
* Compare by last access time (for LRU eviction).
|
||||
@@ -287,13 +289,13 @@ public class DefaultServerCache implements ServerCache {
|
||||
evictCount.add(trimmedByGC);
|
||||
evictCount.add(trimmedByTTL);
|
||||
evictCount.add(trimmedByLRU);
|
||||
if (logger.isTraceEnabled()) {
|
||||
if (logger.isLoggable(TRACE)) {
|
||||
long exeMicros = TimeUnit.MICROSECONDS.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
|
||||
logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}] gc[{}]",
|
||||
logger.log(TRACE, "Executed trim of cache {0} in [{1}]millis idle[{2}] timeToLive[{3}] accessTime[{4}] gc[{5}]",
|
||||
name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU, trimmedByGC);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
|
||||
logger.log(WARNING, "Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
||||
+9
-7
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheRegion;
|
||||
import io.ebean.cache.ServerCacheType;
|
||||
@@ -7,17 +8,18 @@ import io.ebean.meta.MetricVisitor;
|
||||
import io.ebeaninternal.api.SpiCacheRegion;
|
||||
import io.ebeaninternal.server.cluster.ClusterManager;
|
||||
import io.ebeaninternal.server.deploy.DCacheRegion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
/**
|
||||
* Manages the bean and query caches.
|
||||
*/
|
||||
public final class DefaultServerCacheManager implements SpiCacheManager {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.REGION");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.REGION");
|
||||
|
||||
private final Map<String, SpiCacheRegion> regionMap = new HashMap<>();
|
||||
private final ClusterManager clusterManager;
|
||||
@@ -65,23 +67,23 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
|
||||
enabled.add(region.name());
|
||||
if (!region.isEnabled()) {
|
||||
region.setEnabled(true);
|
||||
log.debug("Cache region[{}] enabled", region.name());
|
||||
log.log(DEBUG, "Cache region[{0}] enabled", region.name());
|
||||
}
|
||||
} else {
|
||||
disabled.add(region.name());
|
||||
if (region.isEnabled()) {
|
||||
region.setEnabled(false);
|
||||
log.debug("Cache region[{}] disabled", region.name());
|
||||
log.log(DEBUG, "Cache region[{0}] disabled", region.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("Cache regions enabled:{} disabled:{}", enabled, disabled);
|
||||
log.log(INFO, "Cache regions enabled:{0} disabled:{1}", enabled, disabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllRegionsEnabled(boolean enabled) {
|
||||
log.debug("All cache regions enabled[{}]", enabled);
|
||||
log.log(DEBUG, "All cache regions enabled[{0}]", enabled);
|
||||
for (SpiCacheRegion region : regionMap.values()) {
|
||||
region.setEnabled(enabled);
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public final class RemoteCacheEvent implements BinaryWritable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CacheEvent[ clearAll:" + clearAll + " caches:" + clearCaches + "]";
|
||||
return "CacheEvent clearAll:" + clearAll + " caches:" + clearCaches;
|
||||
}
|
||||
|
||||
public static RemoteCacheEvent readBinaryMessage(BinaryReadContext dataInput) throws IOException {
|
||||
|
||||
+7
-5
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.changelog;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.event.changelog.BeanChange;
|
||||
import io.ebean.event.changelog.ChangeLogListener;
|
||||
import io.ebean.event.changelog.ChangeSet;
|
||||
@@ -7,12 +8,13 @@ import io.ebean.event.changelog.ChangeType;
|
||||
import io.ebean.plugin.Plugin;
|
||||
import io.ebean.plugin.SpiServer;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
/**
|
||||
* Simply logs the change sets in JSON form to logger named <code>io.ebean.ChangeLog</code>.
|
||||
*/
|
||||
@@ -21,7 +23,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
||||
/**
|
||||
* The named logger we send the change set payload to. Can be externally configured as desired.
|
||||
*/
|
||||
private static final Logger changeLog = LoggerFactory.getLogger("io.ebean.ChangeLog");
|
||||
private static final System.Logger changeLog = AppLog.getLogger("io.ebean.ChangeLog");
|
||||
|
||||
/**
|
||||
* Used to build the JSON.
|
||||
@@ -65,9 +67,9 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
||||
try {
|
||||
StringWriter writer = new StringWriter(getBufferSize(beanChange));
|
||||
jsonBuilder.writeBeanJson(writer, beanChange, changeSet);
|
||||
changeLog.info(writer.toString());
|
||||
changeLog.log(INFO, writer.toString());
|
||||
} catch (Exception e) {
|
||||
CoreLog.log.error("Exception logging beanChange " + beanChange, e);
|
||||
CoreLog.log.log(ERROR, "Exception logging beanChange " + beanChange, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class BinaryTransactionEventReader {
|
||||
String serverName = dataInput.readUTF();
|
||||
SpiEbeanServer server = (SpiEbeanServer) serverLookup.getServer(serverName);
|
||||
if (server == null) {
|
||||
throw new IllegalStateException("EbeanServer not found for name [" + serverName + "]");
|
||||
throw new IllegalStateException("Database not found for name " + serverName);
|
||||
}
|
||||
RemoteTransactionEvent event = new RemoteTransactionEvent(server);
|
||||
event.readBinary(dataInput);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package io.ebeaninternal.server.cluster;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.config.ContainerConfig;
|
||||
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Manages the cluster service.
|
||||
*/
|
||||
public class ClusterManager implements ServerLookup {
|
||||
|
||||
private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster");
|
||||
private static final System.Logger clusterLogger = AppLog.getLogger("io.ebean.Cluster");
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
@@ -112,8 +113,8 @@ public class ClusterManager implements ServerLookup {
|
||||
*/
|
||||
public void broadcast(RemoteTransactionEvent event) {
|
||||
if (broadcast != null) {
|
||||
if (clusterLogger.isDebugEnabled()) {
|
||||
clusterLogger.debug("sending: {}", event);
|
||||
if (clusterLogger.isLoggable(DEBUG)) {
|
||||
clusterLogger.log(DEBUG, "sending: {0}", event);
|
||||
}
|
||||
broadcast.broadcast(event);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
|
||||
int firstRow = query.getFirstRow();
|
||||
int maxRows = query.getMaxRows();
|
||||
if (firstRow > 0 || maxRows > 0) {
|
||||
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
|
||||
return server.databasePlatform().basicSqlLimiter().limit(sql, firstRow, maxRows);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -1,484 +0,0 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebeaninternal.server.type.ScalarTypeUUIDBinary;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Default implementation of TypeConverter.
|
||||
* <p>
|
||||
* Converts objects to the required type if required.
|
||||
* </p>
|
||||
*/
|
||||
public final class BasicTypeConverter implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7691463236204070311L;
|
||||
|
||||
/**
|
||||
* Type code for java.util.Calendar.
|
||||
*/
|
||||
public static final int UTIL_CALENDAR = -999998986;
|
||||
|
||||
/**
|
||||
* Type code for java.util.Date.
|
||||
*/
|
||||
public static final int UTIL_DATE = -999998988;
|
||||
|
||||
private BasicTypeConverter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the Object to the required data type.
|
||||
*
|
||||
* @param value the Object value
|
||||
* @param toDataType the dataType as per java.sql.Types.
|
||||
*/
|
||||
public static Object convert(Object value, int toDataType) {
|
||||
|
||||
try {
|
||||
switch (toDataType) {
|
||||
case UTIL_DATE: {
|
||||
return toUtilDate(value);
|
||||
}
|
||||
case UTIL_CALENDAR: {
|
||||
return toCalendar(value);
|
||||
}
|
||||
case Types.BIGINT: {
|
||||
return toLong(value);
|
||||
}
|
||||
case Types.INTEGER: {
|
||||
return toInteger(value);
|
||||
}
|
||||
case Types.BIT: {
|
||||
return toBoolean(value);
|
||||
}
|
||||
case Types.TINYINT: {
|
||||
return toByte(value);
|
||||
}
|
||||
case Types.SMALLINT: {
|
||||
return toShort(value);
|
||||
}
|
||||
case Types.NUMERIC: {
|
||||
return toBigDecimal(value);
|
||||
}
|
||||
case Types.DECIMAL: {
|
||||
return toBigDecimal(value);
|
||||
}
|
||||
case Types.REAL: {
|
||||
return toFloat(value);
|
||||
}
|
||||
case Types.DOUBLE: {
|
||||
return toDouble(value);
|
||||
}
|
||||
case Types.FLOAT: {
|
||||
return toDouble(value);
|
||||
}
|
||||
case Types.BOOLEAN: {
|
||||
return toBoolean(value);
|
||||
}
|
||||
case Types.TIMESTAMP: {
|
||||
return toTimestamp(value);
|
||||
}
|
||||
case Types.DATE: {
|
||||
return toDate(value);
|
||||
}
|
||||
case Types.VARCHAR: {
|
||||
return toString(value);
|
||||
}
|
||||
case Types.CHAR: {
|
||||
return toString(value);
|
||||
}
|
||||
case Types.OTHER: {
|
||||
return value;
|
||||
}
|
||||
case Types.JAVA_OBJECT: {
|
||||
return value;
|
||||
}
|
||||
case Types.BINARY:
|
||||
case Types.LONGVARBINARY:
|
||||
case Types.BLOB: {
|
||||
return value;
|
||||
}
|
||||
case Types.LONGVARCHAR:
|
||||
case Types.CLOB: {
|
||||
return value;
|
||||
}
|
||||
default: {
|
||||
String msg = "Unhandled data type [" + toDataType + "] converting [" + value + "]";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
String m = "ClassCastException converting to data type [" + toDataType + "] value [" + value + "]";
|
||||
throw new RuntimeException(m);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the value to a String.
|
||||
*/
|
||||
public static String toString(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
if (value instanceof char[]) {
|
||||
return String.valueOf((char[]) value);
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert the value to a Boolean with an explicit String true value.
|
||||
*/
|
||||
public static Boolean toBoolean(Object value, String dbTrueValue) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue() == 1;
|
||||
}
|
||||
String s = value.toString();
|
||||
return s.equalsIgnoreCase(dbTrueValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the value to a Boolean. Can be a Boolean or the string values
|
||||
* "true" or "false".
|
||||
*/
|
||||
public static Boolean toBoolean(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
|
||||
return Boolean.valueOf(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the value to a UUID.
|
||||
*/
|
||||
public static UUID toUUID(Object value, boolean optimizedBinary) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof UUID) {
|
||||
return (UUID) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return UUID.fromString((String) value);
|
||||
}
|
||||
if (value instanceof byte[]) {
|
||||
return ScalarTypeUUIDBinary.convertFromBytes((byte[]) value, optimizedBinary);
|
||||
}
|
||||
return UUID.fromString(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a BigDecimal. It should be another
|
||||
* numeric type.
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
return new BigDecimal(value.toString());
|
||||
}
|
||||
|
||||
public static Float toFloat(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
return (Float) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
return Float.valueOf(value.toString());
|
||||
}
|
||||
|
||||
public static Short toShort(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
return (Short) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
return Short.valueOf(value.toString());
|
||||
}
|
||||
|
||||
public static Byte toByte(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
return (Byte) value;
|
||||
}
|
||||
return Byte.valueOf(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a Integer. It should be another numeric
|
||||
* type.
|
||||
*/
|
||||
public static Integer toInteger(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
return Integer.valueOf(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object to a Long. It should be another numeric type.
|
||||
*/
|
||||
public static Long toLong(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return Long.valueOf((String) value);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
if (value instanceof java.util.Date) {
|
||||
return ((java.util.Date) value).getTime();
|
||||
}
|
||||
if (value instanceof Calendar) {
|
||||
return ((Calendar) value).getTime().getTime();
|
||||
}
|
||||
return Long.valueOf(value.toString());
|
||||
}
|
||||
|
||||
public static BigInteger toMathBigInteger(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof BigInteger) {
|
||||
return (BigInteger) value;
|
||||
}
|
||||
return new BigInteger(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object to a Double. It should be another numberic type.
|
||||
*/
|
||||
public static Double toDouble(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
return Double.valueOf(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a Timestamp. It is expected to be a
|
||||
* java.sql.Date really.
|
||||
*/
|
||||
public static Timestamp toTimestamp(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Timestamp) {
|
||||
return (Timestamp) value;
|
||||
|
||||
} else if (value instanceof java.util.Date) {
|
||||
// no nanos here... so hopefully ok
|
||||
return new Timestamp(((java.util.Date) value).getTime());
|
||||
|
||||
} else if (value instanceof Calendar) {
|
||||
return new Timestamp(((Calendar) value).getTime().getTime());
|
||||
|
||||
} else if (value instanceof String) {
|
||||
return Timestamp.valueOf((String) value);
|
||||
|
||||
} else if (value instanceof LocalDateTime) {
|
||||
return Timestamp.valueOf((LocalDateTime) value);
|
||||
|
||||
} else if (value instanceof Number) {
|
||||
return new Timestamp(((Number) value).longValue());
|
||||
|
||||
} else {
|
||||
String msg = "Unable to convert [" + value.getClass().getName() + "] into a Timestamp.";
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static java.sql.Time toTime(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof java.sql.Time) {
|
||||
return (java.sql.Time) value;
|
||||
|
||||
} else if (value instanceof String) {
|
||||
return java.sql.Time.valueOf((String) value);
|
||||
|
||||
} else if (value instanceof LocalTime) {
|
||||
return java.sql.Time.valueOf((LocalTime) value);
|
||||
|
||||
} else {
|
||||
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.sql.Date.";
|
||||
throw new RuntimeException(m);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a java sql Date.
|
||||
*/
|
||||
public static java.sql.Date toDate(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof java.sql.Date) {
|
||||
return (java.sql.Date) value;
|
||||
|
||||
} else if (value instanceof java.util.Date) {
|
||||
return new java.sql.Date(((java.util.Date) value).getTime());
|
||||
|
||||
} else if (value instanceof Calendar) {
|
||||
return new java.sql.Date(((Calendar) value).getTime().getTime());
|
||||
|
||||
} else if (value instanceof String) {
|
||||
return java.sql.Date.valueOf((String) value);
|
||||
|
||||
} else if (value instanceof Number) {
|
||||
return new java.sql.Date(((Number) value).longValue());
|
||||
|
||||
} else if (value instanceof LocalDate) {
|
||||
return java.sql.Date.valueOf((LocalDate)value);
|
||||
|
||||
} else {
|
||||
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.sql.Date.";
|
||||
throw new RuntimeException(m);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a java sql Date.
|
||||
*/
|
||||
public static java.util.Date toUtilDate(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof java.sql.Timestamp) {
|
||||
// loss of nanos precision
|
||||
return new java.util.Date(((java.sql.Timestamp) value).getTime());
|
||||
}
|
||||
// DEVNOTE: strictly speaking do I need to convert a java.sql.Date to
|
||||
// java.util.Date? equals() is symmetrical so perhaps this is not
|
||||
// really required?
|
||||
if (value instanceof java.sql.Date) {
|
||||
return new java.util.Date(((java.sql.Date) value).getTime());
|
||||
}
|
||||
if (value instanceof java.util.Date) {
|
||||
return (java.util.Date) value;
|
||||
|
||||
} else if (value instanceof Calendar) {
|
||||
return ((Calendar) value).getTime();
|
||||
|
||||
} else if (value instanceof String) {
|
||||
return new java.util.Date(Timestamp.valueOf((String) value).getTime());
|
||||
|
||||
} else if (value instanceof Number) {
|
||||
return new java.util.Date(((Number) value).longValue());
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("Unable to convert [" + value.getClass().getName() + "] into a java.util.Date");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the passed in object to a java sql Date.
|
||||
*/
|
||||
public static Calendar toCalendar(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Calendar) {
|
||||
return (Calendar) value;
|
||||
|
||||
} else if (value instanceof java.util.Date) {
|
||||
java.util.Date date = ((java.util.Date) value);
|
||||
return toCalendarFromDate(date);
|
||||
|
||||
} else if (value instanceof String) {
|
||||
java.util.Date date = toUtilDate(value);
|
||||
return toCalendarFromDate(date);
|
||||
|
||||
} else if (value instanceof Number) {
|
||||
long timeMillis = ((Number) value).longValue();
|
||||
java.util.Date date = new java.util.Date(timeMillis);
|
||||
return toCalendarFromDate(date);
|
||||
|
||||
} else {
|
||||
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.util.Date";
|
||||
throw new RuntimeException(m);
|
||||
}
|
||||
}
|
||||
|
||||
private static Calendar toCalendarFromDate(java.util.Date date) {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
|
||||
return cal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Base class for find and persist requests.
|
||||
*/
|
||||
@@ -61,7 +63,7 @@ public abstract class BeanRequest {
|
||||
// Just log this and carry on. A previous exception has been
|
||||
// thrown and if this rollback throws exception it likely means
|
||||
// that the connection is broken (and the dataSource and db will cleanup)
|
||||
CoreLog.log.error("Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||
CoreLog.log.log(ERROR, "Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
/**
|
||||
* Create a DatabasePlatform from the configuration.
|
||||
* <p>
|
||||
@@ -38,7 +41,7 @@ public class DatabasePlatformFactory {
|
||||
try {
|
||||
String offlinePlatform = DbOffline.getPlatform();
|
||||
if (offlinePlatform != null) {
|
||||
CoreLog.log.info("offline platform [{}]", offlinePlatform);
|
||||
CoreLog.log.log(INFO, "offline platform [{0}]", offlinePlatform);
|
||||
return byDatabaseName(offlinePlatform);
|
||||
}
|
||||
if (config.getDatabasePlatformName() != null) {
|
||||
@@ -87,7 +90,7 @@ public class DatabasePlatformFactory {
|
||||
String dbProductName = metaData.getDatabaseProductName().toLowerCase();
|
||||
final int majorVersion = metaData.getDatabaseMajorVersion();
|
||||
final int minorVersion = metaData.getDatabaseMinorVersion();
|
||||
CoreLog.log.debug("platform for productName[{}] version[{}.{}]", dbProductName, majorVersion, minorVersion);
|
||||
CoreLog.log.log(DEBUG, "platform for productName[{0}] version[{1}.{2}]", dbProductName, majorVersion, minorVersion);
|
||||
for (DatabasePlatformProvider provider : providers) {
|
||||
if (provider.matchByProductName(dbProductName)) {
|
||||
return provider.create(majorVersion, minorVersion, metaData, connection);
|
||||
|
||||
@@ -12,18 +12,19 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Helper to handle lazy loading and refreshing of beans.
|
||||
*/
|
||||
final class DefaultBeanLoader {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final DefaultServer server;
|
||||
private final boolean onIterateUseExtraTxn;
|
||||
@@ -108,8 +109,8 @@ final class DefaultBeanLoader {
|
||||
server.findOne(query, null);
|
||||
if (beanCollection != null) {
|
||||
if (beanCollection.checkEmptyLazyLoad()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("BeanCollection after load was empty. Owner:" + beanCollection.getOwnerBean());
|
||||
if (log.isLoggable(DEBUG)) {
|
||||
log.log(DEBUG, "BeanCollection after load was empty. Owner:{0}", beanCollection.getOwnerBean());
|
||||
}
|
||||
} else if (useManyIdCache) {
|
||||
parentDesc.cacheManyPropPut(many, beanCollection, parentId);
|
||||
@@ -228,7 +229,7 @@ final class DefaultBeanLoader {
|
||||
|
||||
Object dbBean = query.findOne();
|
||||
if (dbBean == null) {
|
||||
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
|
||||
throw new EntityNotFoundException("Bean not found during lazy load or refresh. Id:" + id + " type:" + desc.type());
|
||||
}
|
||||
desc.resetManyProperties(dbBean);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.config.*;
|
||||
import io.ebean.config.EntityClassRegister;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.event.ShutdownManager;
|
||||
import io.ebean.service.SpiContainer;
|
||||
@@ -13,7 +12,6 @@ import io.ebeaninternal.server.cluster.ClusterManager;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.net.URL;
|
||||
@@ -23,12 +21,14 @@ import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
/**
|
||||
* Default Server side implementation of ServerFactory.
|
||||
*/
|
||||
public final class DefaultContainer implements SpiContainer {
|
||||
|
||||
private static final Logger log = CoreLog.log;
|
||||
private static final System.Logger log = CoreLog.log;
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final ClusterManager clusterManager;
|
||||
@@ -108,7 +108,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
startServer(online, server);
|
||||
}
|
||||
DbOffline.reset();
|
||||
log.info("Started database[{}] platform[{}] in {}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
|
||||
log.log(INFO, "Started database[{0}] platform[{1}] in {2}ms", config.getName(), config.getDatabasePlatform().platform(), System.currentTimeMillis() - start);
|
||||
return server;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -137,7 +137,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
private void checkMissingModulePathProvides() {
|
||||
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.EntityClassRegister");
|
||||
if (servicesFile != null) {
|
||||
log.error("module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
|
||||
log.log(ERROR, "module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
DatabasePlatform platform = config.getDatabasePlatform();
|
||||
if (platform == null) {
|
||||
if (config.getTenantMode().isDynamicDataSource()) {
|
||||
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode "+config.getTenantMode());
|
||||
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode " + config.getTenantMode());
|
||||
}
|
||||
// automatically determine the platform
|
||||
platform = new DatabasePlatformFactory().create(config);
|
||||
@@ -215,7 +215,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
*/
|
||||
private void setDataSource(DatabaseConfig config) {
|
||||
if (isOfflineMode(config)) {
|
||||
log.debug("... DbOffline using platform [{}]", DbOffline.getPlatform());
|
||||
log.log(DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform());
|
||||
} else {
|
||||
InitDataSource.init(config);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
}
|
||||
try (Connection connection = config.getDataSource().getConnection()) {
|
||||
if (connection.getAutoCommit()) {
|
||||
log.warn("DataSource [{}] has autoCommit defaulting to true!", config.getName());
|
||||
log.log(WARNING, "DataSource [{0}] has autoCommit defaulting to true!", config.getName());
|
||||
}
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.config.QueryPlanCapture;
|
||||
import io.ebean.config.QueryPlanListener;
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
final class DefaultQueryPlanListener implements QueryPlanListener {
|
||||
|
||||
static final QueryPlanListener INSTANT = new DefaultQueryPlanListener();
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.QUERYPLAN");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.QUERYPLAN");
|
||||
|
||||
@Override
|
||||
public void process(QueryPlanCapture capture) {
|
||||
// better to log this in JSON form?
|
||||
String dbName = capture.database().name();
|
||||
for (MetaQueryPlan plan : capture.plans()) {
|
||||
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
||||
log.log(INFO, "queryPlan db:{0} label:{1} queryTimeMicros:{2} loc:{3} sql:{4} bind:{5} plan:{6}",
|
||||
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||
plan.sql(), plan.bind(), plan.plan());
|
||||
}
|
||||
|
||||
@@ -2,49 +2,11 @@ package io.ebeaninternal.server.core;
|
||||
|
||||
import io.avaje.lang.NonNullApi;
|
||||
import io.avaje.lang.Nullable;
|
||||
import io.ebean.AutoTune;
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.BeanState;
|
||||
import io.ebean.CallableSql;
|
||||
import io.ebean.DocumentStore;
|
||||
import io.ebean.DtoQuery;
|
||||
import io.ebean.ExpressionFactory;
|
||||
import io.ebean.ExpressionList;
|
||||
import io.ebean.ExtendedServer;
|
||||
import io.ebean.Filter;
|
||||
import io.ebean.FutureIds;
|
||||
import io.ebean.FutureList;
|
||||
import io.ebean.FutureRowCount;
|
||||
import io.ebean.MergeOptions;
|
||||
import io.ebean.MergeOptionsBuilder;
|
||||
import io.ebean.PagedList;
|
||||
import io.ebean.PersistenceContextScope;
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.QueryIterator;
|
||||
import io.ebean.RowConsumer;
|
||||
import io.ebean.RowMapper;
|
||||
import io.ebean.ScriptRunner;
|
||||
import io.ebean.SqlQuery;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.SqlUpdate;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TransactionCallback;
|
||||
import io.ebean.TxScope;
|
||||
import io.ebean.Update;
|
||||
import io.ebean.UpdateQuery;
|
||||
import io.ebean.ValuePair;
|
||||
import io.ebean.Version;
|
||||
import io.ebean.*;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.TxIsolation;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.BeanLoader;
|
||||
import io.ebean.bean.CallOrigin;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebean.bean.*;
|
||||
import io.ebean.bean.PersistenceContext.WithOption;
|
||||
import io.ebean.bean.SingleBeanLoader;
|
||||
import io.ebean.cache.ServerCacheManager;
|
||||
import io.ebean.common.CopyOnFirstWriteList;
|
||||
import io.ebean.config.*;
|
||||
@@ -53,17 +15,12 @@ import io.ebean.event.BeanPersistController;
|
||||
import io.ebean.event.ShutdownManager;
|
||||
import io.ebean.event.readaudit.ReadAuditLogger;
|
||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import io.ebean.meta.MetaInfoManager;
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.meta.QueryPlanInit;
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
import io.ebean.meta.*;
|
||||
import io.ebean.migration.auto.AutoMigrationRunner;
|
||||
import io.ebean.plugin.BeanType;
|
||||
import io.ebean.plugin.Plugin;
|
||||
import io.ebean.plugin.Property;
|
||||
import io.ebean.plugin.SpiServer;
|
||||
import io.ebean.text.csv.CsvReader;
|
||||
import io.ebean.text.json.JsonContext;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
@@ -78,30 +35,15 @@ import io.ebeaninternal.server.dto.DtoBeanDescriptor;
|
||||
import io.ebeaninternal.server.dto.DtoBeanManager;
|
||||
import io.ebeaninternal.server.el.ElFilter;
|
||||
import io.ebeaninternal.server.grammer.EqlParser;
|
||||
import io.ebeaninternal.server.query.CQuery;
|
||||
import io.ebeaninternal.server.query.CQueryEngine;
|
||||
import io.ebeaninternal.server.query.CallableQueryCount;
|
||||
import io.ebeaninternal.server.query.CallableQueryIds;
|
||||
import io.ebeaninternal.server.query.CallableQueryList;
|
||||
import io.ebeaninternal.server.query.DtoQueryEngine;
|
||||
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.querydefn.DefaultDtoQuery;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmUpdate;
|
||||
import io.ebeaninternal.server.querydefn.DefaultRelationalQuery;
|
||||
import io.ebeaninternal.server.querydefn.DefaultUpdateQuery;
|
||||
import io.ebeaninternal.server.query.*;
|
||||
import io.ebeaninternal.server.querydefn.*;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.server.text.csv.TCsvReader;
|
||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
||||
import io.ebeaninternal.server.transaction.TransactionManager;
|
||||
import io.ebeaninternal.util.ParamTypeHelper;
|
||||
import io.ebeaninternal.util.ParamTypeHelper.TypeInfo;
|
||||
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.NonUniqueResultException;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
@@ -120,6 +62,7 @@ import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
import static java.util.Spliterators.spliteratorUnknownSize;
|
||||
import static java.util.stream.StreamSupport.stream;
|
||||
|
||||
@@ -129,7 +72,7 @@ import static java.util.stream.StreamSupport.stream;
|
||||
@NonNullApi
|
||||
public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final DatabaseConfig config;
|
||||
@@ -306,7 +249,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public Platform platform() {
|
||||
return databasePlatform.getPlatform();
|
||||
return databasePlatform.platform();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -373,7 +316,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
migrationRunner.setDefaultDbSchema(dbSchema);
|
||||
}
|
||||
migrationRunner.setName(config.getName());
|
||||
Platform platform = config.getDatabasePlatform().getPlatform();
|
||||
Platform platform = config.getDatabasePlatform().platform();
|
||||
migrationRunner.setBasePlatform(platform.base().name().toLowerCase());
|
||||
migrationRunner.setPlatform(platform.name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
@@ -386,7 +329,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (config.isQueryPlanCapture()) {
|
||||
long secs = config.getQueryPlanCapturePeriodSecs();
|
||||
if (secs > 10) {
|
||||
log.info("capture query plan enabled, every {}secs", secs);
|
||||
log.log(INFO, "capture query plan enabled, every {0}secs", secs);
|
||||
backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -434,7 +377,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Shutdown the services like threads and DataSource.
|
||||
*/
|
||||
private void shutdownInternal(boolean shutdownDataSource, boolean deregisterDriver) {
|
||||
log.trace("shutting down instance {}", serverName);
|
||||
log.log(TRACE, "shutting down instance {0}", serverName);
|
||||
if (shutdown) {
|
||||
// already shutdown
|
||||
return;
|
||||
@@ -463,7 +406,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
try {
|
||||
plugin.shutdown();
|
||||
} catch (Exception e) {
|
||||
log.error("Error when shutting down plugin", e);
|
||||
log.log(ERROR, "Error when shutting down plugin", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -615,7 +558,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
try (Connection connection = dataSource().getConnection()) {
|
||||
for (String table : tables) {
|
||||
executeSql(connection, databasePlatform.truncateStatement(table));
|
||||
if (databasePlatform.getPlatform().base() == Platform.DB2) {
|
||||
if (databasePlatform.platform().base() == Platform.DB2) {
|
||||
// DB2 requires commit after each truncate statement
|
||||
connection.commit();
|
||||
}
|
||||
@@ -862,10 +805,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return new ElFilter<>(desc(beanType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
|
||||
return new TCsvReader<>(this, desc(beanType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UpdateQuery<T> update(Class<T> beanType) {
|
||||
@@ -1140,7 +1079,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
} else if (list.size() > 1) {
|
||||
throw new NonUniqueResultException("Unique expecting 0 or 1 results but got [" + list.size() + "]");
|
||||
throw new NonUniqueResultException("Unique expecting 0 or 1 results but got " + list.size());
|
||||
} else {
|
||||
return list.get(0);
|
||||
}
|
||||
@@ -1330,7 +1269,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
copy.setFutureFetch(true);
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureRowCount<T> queryFuture = new QueryFutureRowCount<>(new CallableQueryCount<>(this, copy, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
@@ -1340,7 +1279,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
copy.setFutureFetch(true);
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureIds<T> queryFuture = new QueryFutureIds<>(new CallableQueryIds<>(this, copy, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
@@ -1357,7 +1296,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
// Create a new transaction solely to execute the findList() at some future time
|
||||
Transaction newTxn = createTransaction();
|
||||
QueryFutureList<T> queryFuture = new QueryFutureList<>(new CallableQueryList<>(this, spiQuery, newTxn));
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
backgroundExecutor.execute(queryFuture.futureTask());
|
||||
return queryFuture;
|
||||
}
|
||||
|
||||
@@ -2038,7 +1977,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return desc(bean.getClass()).getId(eb);
|
||||
}
|
||||
|
||||
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
|
||||
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
|
||||
BeanDescriptor<T> desc = descriptorManager.descriptor(beanClass);
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(beanClass.getName() + " is NOT an Entity Bean registered with this server?");
|
||||
@@ -2130,7 +2069,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
try {
|
||||
serverCacheManager.clearLocal(Class.forName(cache));
|
||||
} catch (Exception e) {
|
||||
log.error("Error clearing local cache for type " + cache, e);
|
||||
log.log(ERROR, "Error clearing local cache for type " + cache, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.bean.ObjectGraphNode;
|
||||
import io.ebean.config.SlowQueryEvent;
|
||||
import io.ebean.config.SlowQueryListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
/**
|
||||
* Default slow query listener implementation that logs a warning message.
|
||||
*/
|
||||
final class DefaultSlowQueryListener implements SlowQueryListener {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.SlowQuery");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.SlowQuery");
|
||||
|
||||
@Override
|
||||
public void process(SlowQueryEvent event) {
|
||||
@@ -20,6 +21,6 @@ final class DefaultSlowQueryListener implements SlowQueryListener {
|
||||
if (node != null) {
|
||||
firstStack = node.getOriginQueryPoint().getTopElement();
|
||||
}
|
||||
log.warn("Slow query warning - millis:{} rows:{} caller[{}] sql[{}]", event.getTimeMillis(), event.getRowCount(), firstStack, event.getSql());
|
||||
log.log(WARNING, "Slow query warning - millis:{0} rows:{1} caller[{2}] sql[{3}]", event.getTimeMillis(), event.getRowCount(), firstStack, event.getSql());
|
||||
}
|
||||
}
|
||||
@@ -100,11 +100,7 @@ final class DumpMetrics {
|
||||
}
|
||||
|
||||
private void logCount(MetaCountMetric metric) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(padNameTimed(metric.name())).append(" ");
|
||||
sb.append(" count:").append(pad(metric.count()));
|
||||
out(sb.toString());
|
||||
out(padNameTimed(metric.name()) + " count:" + pad(metric.count()));
|
||||
}
|
||||
|
||||
private void out(String sb) {
|
||||
|
||||
@@ -105,7 +105,7 @@ final class InitDataSource {
|
||||
}
|
||||
|
||||
boolean isPostgresAllQuotedIdentifiers() {
|
||||
return config.isAllQuotedIdentifiers() && Platform.POSTGRES == config.getDatabasePlatform().getPlatform().base();
|
||||
return config.isAllQuotedIdentifiers() && Platform.POSTGRES == config.getDatabasePlatform().platform().base();
|
||||
}
|
||||
|
||||
private DataSource create(DataSourceConfig dsConfig, boolean readOnly) {
|
||||
|
||||
@@ -1,38 +1,14 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Used to reduce memory consumption of strings used in deployment processing.
|
||||
* <p>
|
||||
* Using this for now instead of String.intern() to avoid any unexpected
|
||||
* increase in PermGen space.
|
||||
*/
|
||||
public final class InternString {
|
||||
|
||||
private static final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
private static final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* Return the shared instance of this string.
|
||||
*/
|
||||
public static String intern(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
lock.lock();
|
||||
try {
|
||||
String v = map.get(s);
|
||||
if (v != null) {
|
||||
return v;
|
||||
} else {
|
||||
map.put(s, s);
|
||||
return s;
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
return s == null ? null : s.intern();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Reads the Xml deployment information.
|
||||
*/
|
||||
@@ -55,7 +57,7 @@ final class InternalConfigXmlMap {
|
||||
try {
|
||||
dtoClass = Class.forName(dto.getClazz(), false, classLoader);
|
||||
} catch (Exception e) {
|
||||
CoreLog.internal.error("Could not load dto bean class " + dto.getClazz() + " for ebean xml entry");
|
||||
CoreLog.internal.log(ERROR, "Could not load dto bean class " + dto.getClazz() + " for ebean xml entry");
|
||||
return;
|
||||
}
|
||||
DtoNamedQueries namedQueries = dtoNamedQueries.computeIfAbsent(dtoClass, aClass -> new DtoNamedQueries());
|
||||
|
||||
@@ -46,7 +46,7 @@ import io.ebeaninternal.server.persist.platform.PostgresMultiValueBind;
|
||||
import io.ebeaninternal.server.query.*;
|
||||
import io.ebeaninternal.server.readaudit.DefaultReadAuditLogger;
|
||||
import io.ebeaninternal.server.readaudit.DefaultReadAuditPrepare;
|
||||
import io.ebeaninternal.server.text.json.DJsonContext;
|
||||
import io.ebeaninternal.server.json.DJsonContext;
|
||||
import io.ebeaninternal.server.transaction.*;
|
||||
import io.ebeaninternal.server.type.DefaultTypeManager;
|
||||
import io.ebeaninternal.server.type.TypeManager;
|
||||
@@ -56,17 +56,18 @@ import io.ebeanservice.docstore.api.DocStoreFactory;
|
||||
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
||||
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
||||
import io.ebeanservice.docstore.none.NoneDocStoreFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
/**
|
||||
* Used to extend the DatabaseConfig with additional objects used to configure and
|
||||
* construct an Database.
|
||||
*/
|
||||
public final class InternalConfiguration {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final TableModState tableModState;
|
||||
private final boolean online;
|
||||
@@ -115,7 +116,7 @@ public final class InternalConfiguration {
|
||||
this.databasePlatform = config.getDatabasePlatform();
|
||||
this.expressionFactory = initExpressionFactory(config);
|
||||
this.typeManager = new DefaultTypeManager(config, bootupClasses);
|
||||
this.multiValueBind = createMultiValueBind(databasePlatform.getPlatform());
|
||||
this.multiValueBind = createMultiValueBind(databasePlatform.platform());
|
||||
this.deployInherit = new DeployInherit(bootupClasses);
|
||||
this.deployCreateProperties = new DeployCreateProperties(typeManager);
|
||||
this.deployUtil = new DeployUtil(typeManager, config);
|
||||
@@ -170,7 +171,7 @@ public final class InternalConfiguration {
|
||||
* Create and return the ExpressionFactory based on configuration and database platform.
|
||||
*/
|
||||
private ExpressionFactory initExpressionFactory(DatabaseConfig config) {
|
||||
boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.isSupportsNativeIlike();
|
||||
boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.supportsNativeIlike();
|
||||
return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike);
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ public final class InternalConfiguration {
|
||||
*/
|
||||
ReadAuditLogger getReadAuditLogger() {
|
||||
ReadAuditLogger found = bootupClasses.getReadAuditLogger();
|
||||
return plugin(found != null ? found : jacksonCorePresent? new DefaultReadAuditLogger(): null);
|
||||
return plugin(found != null ? found : jacksonCorePresent ? new DefaultReadAuditLogger() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +265,7 @@ public final class InternalConfiguration {
|
||||
|
||||
DbExpressionHandler jsonHandler = getDbExpressionHandler(databasePlatform);
|
||||
|
||||
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||
DbHistorySupport historySupport = databasePlatform.historySupport();
|
||||
if (historySupport == null) {
|
||||
return new Binder(typeManager, logManager, 0, false, jsonHandler, dataTimeZone, multiValueBind);
|
||||
}
|
||||
@@ -320,7 +321,7 @@ public final class InternalConfiguration {
|
||||
}
|
||||
|
||||
private Platform getPlatform() {
|
||||
return getDatabasePlatform().getPlatform();
|
||||
return getDatabasePlatform().platform();
|
||||
}
|
||||
|
||||
public DatabasePlatform getDatabasePlatform() {
|
||||
@@ -433,7 +434,7 @@ public final class InternalConfiguration {
|
||||
externalTransactionManager = new JtaTransactionManager();
|
||||
}
|
||||
if (externalTransactionManager != null) {
|
||||
log.info("Using Transaction Manager [" + externalTransactionManager.getClass() + "]");
|
||||
log.log(INFO, "Using Transaction Manager {0}", externalTransactionManager.getClass());
|
||||
return new ExternalTransactionScopeManager(externalTransactionManager);
|
||||
} else {
|
||||
return new DefaultTransactionScopeManager();
|
||||
@@ -523,7 +524,7 @@ public final class InternalConfiguration {
|
||||
if (iterator.hasNext()) {
|
||||
// use the cacheFactory (via classpath service loader)
|
||||
plugin = iterator.next();
|
||||
log.debug("using ServerCacheFactory {}", plugin.getClass());
|
||||
log.log(DEBUG, "using ServerCacheFactory {0}", plugin.getClass());
|
||||
} else {
|
||||
// use the built in default l2 caching which is local cache based
|
||||
localL2Caching = true;
|
||||
@@ -576,7 +577,7 @@ public final class InternalConfiguration {
|
||||
return QueryPlanManager.NOOP;
|
||||
}
|
||||
long threshold = config.getQueryPlanThresholdMicros();
|
||||
return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.getPlatform()), extraMetrics);
|
||||
return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.platform()), extraMetrics);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -605,6 +606,7 @@ public final class InternalConfiguration {
|
||||
|
||||
private static class NoopDdl implements SpiDdlGenerator {
|
||||
private final boolean ddlRun;
|
||||
|
||||
NoopDdl(boolean ddlRun) {
|
||||
this.ddlRun = ddlRun;
|
||||
}
|
||||
@@ -612,7 +614,7 @@ public final class InternalConfiguration {
|
||||
@Override
|
||||
public void execute(boolean online) {
|
||||
if (online && ddlRun) {
|
||||
CoreLog.log.error("Configured to run DDL but ebean-ddl-generator is not in the classpath (or ebean-test in the test classpath?)");
|
||||
CoreLog.log.log(ERROR, "Configured to run DDL but ebean-ddl-generator is not in the classpath (or ebean-test in the test classpath?)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface OrmQueryEngine {
|
||||
* Return true if multi-value bind is supported for this type (and current platform).
|
||||
*/
|
||||
boolean isMultiValueSupported(Class<?> valueType);
|
||||
|
||||
int forwardOnlyFetchSize();
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Wraps the objects involved in executing a Query.
|
||||
*/
|
||||
@@ -98,7 +100,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
*/
|
||||
@Override
|
||||
public String dbLikeClause(boolean rawLikeExpression) {
|
||||
return server.databasePlatform().getLikeClause(rawLikeExpression);
|
||||
return server.databasePlatform().likeClause(rawLikeExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +246,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
// Just log this and carry on. A previous exception has been
|
||||
// thrown and if this rollback throws exception it likely means
|
||||
// that the connection is broken (and the dataSource and db will cleanup)
|
||||
CoreLog.log.error("Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||
CoreLog.log.log(ERROR, "Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,7 +641,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
for (T bean : actualDetails) {
|
||||
ids.add(beanDescriptor.idForJson(bean));
|
||||
}
|
||||
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
|
||||
beanDescriptor.readAuditMany(queryPlanKey.partialKey(), "l2-query-cache", ids);
|
||||
}
|
||||
}
|
||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||
@@ -759,6 +761,10 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return true if no MaxRows or use LIMIT in SQL update.
|
||||
*/
|
||||
public boolean isInlineSqlUpdateLimit() {
|
||||
return query.getMaxRows() < 1 || server.databasePlatform().isInlineSqlUpdateLimit();
|
||||
return query.getMaxRows() < 1 || server.databasePlatform().inlineSqlUpdateLimit();
|
||||
}
|
||||
|
||||
public int forwardOnlyFetchSize() {
|
||||
return queryEngine.forwardOnlyFetchSize();
|
||||
}
|
||||
}
|
||||
@@ -928,20 +928,20 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
private void logSummaryMessage() {
|
||||
String draft = (beanDescriptor.isDraftable() && !publish) ? " draft[true]" : "";
|
||||
String draft = (beanDescriptor.isDraftable() && !publish) ? "] draft[true]" : "]";
|
||||
String name = beanDescriptor.name();
|
||||
switch (type) {
|
||||
case INSERT:
|
||||
transaction.logSummary("Inserted [" + name + "] [" + (idValue == null ? "" : idValue) + "]" + draft);
|
||||
transaction.logSummary("Inserted [" + name + "] [" + (idValue == null ? "" : idValue) + draft);
|
||||
break;
|
||||
case UPDATE:
|
||||
transaction.logSummary("Updated [" + name + "] [" + idValue + "]" + draft);
|
||||
transaction.logSummary("Updated [" + name + "] [" + idValue + draft);
|
||||
break;
|
||||
case DELETE:
|
||||
transaction.logSummary("Deleted [" + name + "] [" + idValue + "]" + draft);
|
||||
transaction.logSummary("Deleted [" + name + "] [" + idValue + draft);
|
||||
break;
|
||||
case DELETE_SOFT:
|
||||
transaction.logSummary("SoftDelete [" + name + "] [" + idValue + "]" + draft);
|
||||
transaction.logSummary("SoftDelete [" + name + "] [" + idValue + draft);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+1
-2
@@ -86,8 +86,7 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
persistExecute.collectSqlCall(label, startNanos);
|
||||
}
|
||||
if (transaction.isLogSummary()) {
|
||||
String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount + "]" + " bind[" + bindLog + "]";
|
||||
transaction.logSummary(m);
|
||||
transaction.logSummary("CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount + "]" + " bind[" + bindLog + "]");
|
||||
}
|
||||
|
||||
// register table modifications with the transaction event
|
||||
|
||||
@@ -83,8 +83,7 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType();
|
||||
String tableName = ormUpdate.getBaseTable();
|
||||
if (transaction.isLogSummary()) {
|
||||
String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
|
||||
transaction.logSummary(m);
|
||||
transaction.logSummary(ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]");
|
||||
}
|
||||
if (ormUpdate.isNotifyCache()) {
|
||||
// add the modification info to the TransactionEvent
|
||||
|
||||
@@ -49,9 +49,9 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
/**
|
||||
* Add this statement to JDBC batch for later execution.
|
||||
*/
|
||||
public int addBatch() {
|
||||
public void addBatch() {
|
||||
this.addBatch = true;
|
||||
return executeStatement(true);
|
||||
executeStatement(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -138,7 +138,7 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
||||
/**
|
||||
* Maybe hit the bean cache returning true if everything was obtained from the
|
||||
* cache (that there were no misses).
|
||||
*
|
||||
* <p>
|
||||
* Do this for findList() on many natural keys or many Ids.
|
||||
*/
|
||||
boolean getFromBeanCache();
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.sql.ResultSet;
|
||||
|
||||
/**
|
||||
* Hold the JDBC PreparedStatement and ResultSet.
|
||||
*
|
||||
* <p>
|
||||
* These both must be closed properly when done.
|
||||
*/
|
||||
public final class SpiResultSet {
|
||||
|
||||
+4
-4
@@ -4,17 +4,18 @@ import io.avaje.classpath.scanner.ClassPathScanner;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.server.core.ClassPathScanners;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Searches for interesting classes such as Entities, Embedded and ScalarTypes.
|
||||
*/
|
||||
public class BootupClassPathSearch {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final List<String> packages;
|
||||
private final List<ClassPathScanner> scanners;
|
||||
@@ -42,7 +43,6 @@ public class BootupClassPathSearch {
|
||||
* Search the classPath for the classes we are interested in.
|
||||
*/
|
||||
private BootupClasses getBootupClasses() {
|
||||
|
||||
try {
|
||||
BootupClasses bc = new BootupClasses();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BootupClassPathSearch {
|
||||
}
|
||||
|
||||
long searchTime = System.currentTimeMillis() - st;
|
||||
log.debug("Classpath search entities[{}] searchTime[{}] in packages[{}]", bc.getEntities().size(), searchTime, packages);
|
||||
log.log(DEBUG, "Classpath search entities[{0}] searchTime[{1}] in packages[{2}]", bc.getEntities().size(), searchTime, packages);
|
||||
return bc;
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.ebean.event.readaudit.ReadAuditLogger;
|
||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import io.ebean.util.AnnotationUtil;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Embeddable;
|
||||
@@ -25,13 +24,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Interesting classes for a EbeanServer such as Embeddable, Entity,
|
||||
* ScalarTypes, Finders, Listeners and Controllers.
|
||||
*/
|
||||
public class BootupClasses implements Predicate<Class<?>> {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final List<Class<?>> embeddableList = new ArrayList<>();
|
||||
private final List<Class<?>> entityList = new ArrayList<>();
|
||||
@@ -205,13 +207,13 @@ public class BootupClasses implements Predicate<Class<?>> {
|
||||
try {
|
||||
return cls.getConstructor().newInstance();
|
||||
} catch (NoSuchMethodException e) {
|
||||
log.debug("Ignore/expected - no default constructor: " +e.getMessage());
|
||||
log.log(DEBUG, "Ignore/expected - no default constructor: {0}", e.getMessage());
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
if (logOnException) {
|
||||
// not expected but we log and carry on
|
||||
log.error("Error creating " + cls, e);
|
||||
log.log(ERROR, "Error creating " + cls, e);
|
||||
return null;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.core.bootup;
|
||||
import io.ebean.util.StringHelper;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.util.UrlHelper;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -15,12 +14,14 @@ import java.util.Set;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
/**
|
||||
* Reads all the META-INF/ebean.mf resources with the package locations of entity beans.
|
||||
*/
|
||||
class ManifestReader {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final Set<String> packageSet = new HashSet<>();
|
||||
private final ClassLoader classLoader;
|
||||
@@ -54,8 +55,7 @@ class ManifestReader {
|
||||
/**
|
||||
* Read all the specific manifest files and return the set of packages containing type query beans.
|
||||
*/
|
||||
private Set<String> read(ClassLoader classLoader, String resourcePath) {
|
||||
|
||||
private void read(ClassLoader classLoader, String resourcePath) {
|
||||
try {
|
||||
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
||||
while (resources.hasMoreElements()) {
|
||||
@@ -64,16 +64,14 @@ class ManifestReader {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.warn("Error reading " + resourcePath + " manifest resources", e);
|
||||
log.log(WARNING, "Error reading " + resourcePath + " manifest resources", e);
|
||||
}
|
||||
return packageSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the entity packages from the manifest.
|
||||
*/
|
||||
private void read(Manifest manifest) throws IOException {
|
||||
|
||||
Attributes attributes = manifest.getMainAttributes();
|
||||
String agentOnlyUse = attributes.getValue("agent-use-only");
|
||||
if (agentOnlyUse == null || !"true".equalsIgnoreCase(agentOnlyUse.trim())) {
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class AssocOneHelp {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
PersistenceContext pc = ctx.getPersistenceContext();
|
||||
PersistenceContext pc = ctx.persistenceContext();
|
||||
Object existing = target.contextGet(pc, id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
@Override
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
// set appropriate tableAlias for the exported id columns
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
ctx.pushTableAlias(relativePrefix);
|
||||
property.targetIdBinder.appendSelect(ctx, subQuery);
|
||||
ctx.popTableAlias();
|
||||
@@ -30,7 +30,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
|
||||
@Override
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
if (softDelete && !ctx.isIncludeSoftDelete()) {
|
||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
@Override
|
||||
void loadIgnore(DbReadContext ctx) {
|
||||
property.targetIdBinder.loadIgnore(ctx);
|
||||
ctx.getDataReader().incrementPos(1);
|
||||
ctx.dataReader().incrementPos(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
return null;
|
||||
}
|
||||
// check transaction context to see if it already exists
|
||||
PersistenceContext pc = ctx.getPersistenceContext();
|
||||
PersistenceContext pc = ctx.persistenceContext();
|
||||
Object existing = desc.contextGet(pc, id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
@@ -63,7 +63,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
// add join to support the discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name);
|
||||
String relativePrefix = ctx.relativePrefix(property.name);
|
||||
ctx.addExtraJoin(new Extra(relativePrefix, joinType));
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
if (!subQuery) {
|
||||
// add discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String tableAlias = ctx.getTableAlias(relativePrefix);
|
||||
String relativePrefix = ctx.relativePrefix(property.name());
|
||||
String tableAlias = ctx.tableAlias(relativePrefix);
|
||||
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
|
||||
}
|
||||
property.importedId.sqlAppend(ctx);
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class BeanCollectionUtil {
|
||||
} else if (o instanceof Collection<?>) {
|
||||
return ((Collection<?>) o);
|
||||
}
|
||||
throw new PersistenceException("expecting a Map or Collection but got [" + o.getClass().getName() + "]");
|
||||
throw new PersistenceException("expecting a Map or Collection but got " + o.getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +73,6 @@ public final class BeanCollectionUtil {
|
||||
} else if (o instanceof Collection<?>) {
|
||||
return ((Collection<?>) o);
|
||||
}
|
||||
throw new PersistenceException("expecting a Map or Collection but got [" + o.getClass().getName() + "]");
|
||||
throw new PersistenceException("expecting a Map or Collection but got " + o.getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
import io.ebeaninternal.util.SortByClause;
|
||||
import io.ebeaninternal.util.SortByClauseParser;
|
||||
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||
@@ -54,7 +54,6 @@ import io.ebeanservice.docstore.api.DocStoreUpdates;
|
||||
import io.ebeanservice.docstore.api.mapping.DocMappingBuilder;
|
||||
import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
||||
import io.ebeanservice.docstore.api.mapping.DocumentMapping;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
@@ -68,13 +67,15 @@ import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
/**
|
||||
* Describes Beans including their deployment information.
|
||||
*/
|
||||
public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
public enum EntityType {
|
||||
ORM, EMBEDDED, VIEW, SQL, DOC
|
||||
@@ -322,7 +323,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
this.jsonHelp = initJsonHelp();
|
||||
this.draftHelp = new BeanDescriptorDraftHelp<>(this);
|
||||
this.docStoreAdapter = owner.createDocStoreBeanAdapter(this, deploy);
|
||||
this.docStoreQueueId = docStoreAdapter.getQueueId();
|
||||
this.docStoreQueueId = docStoreAdapter.queueId();
|
||||
// Check if there are no cascade save associated beans ( subject to change
|
||||
// in initialiseOther()). Note that if we are in an inheritance hierarchy
|
||||
// then we also need to check every BeanDescriptors in the InheritInfo as
|
||||
@@ -494,9 +495,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* as they are used to get the imported and exported properties.
|
||||
*/
|
||||
void initialiseId(BeanDescriptorInitContext initContext) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("BeanDescriptor initialise " + fullName);
|
||||
}
|
||||
if (draftable) {
|
||||
initContext.addDraft(baseTable, draftTable);
|
||||
}
|
||||
@@ -795,7 +793,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
changeJson.flush();
|
||||
return beanChange(ChangeType.UPDATE, request.beanId(), changeJson.newJson(), changeJson.oldJson());
|
||||
} catch (RuntimeException e) {
|
||||
log.error("Failed to write ChangeLog entry for update", e);
|
||||
log.log(ERROR, "Failed to write ChangeLog entry for update", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -811,7 +809,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
jsonWriter.flush();
|
||||
return beanChange(ChangeType.INSERT, request.beanId(), writer.toString(), null);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to write ChangeLog entry for insert", e);
|
||||
log.log(ERROR, "Failed to write ChangeLog entry for insert", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -968,7 +966,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
*/
|
||||
@Override
|
||||
public boolean isDocStoreMapped() {
|
||||
return docStoreAdapter.isMapped();
|
||||
return docStoreAdapter.mapped();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1074,7 +1072,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* given the transactions requested mode.
|
||||
*/
|
||||
public DocStoreMode docStoreMode(PersistRequest.Type persistType, DocStoreMode txnMode) {
|
||||
return docStoreAdapter.getMode(persistType, txnMode);
|
||||
return docStoreAdapter.mode(persistType, txnMode);
|
||||
}
|
||||
|
||||
public void docStoreInsert(Object idValue, PersistRequestBean<T> persistRequest, DocStoreUpdateContext bulkUpdate) throws IOException {
|
||||
@@ -1468,7 +1466,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
|
||||
void queryPlanInit(QueryPlanInit request, List<MetaQueryPlan> list) {
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
if (request.includeHash(queryPlan.getHash())) {
|
||||
if (request.includeHash(queryPlan.hash())) {
|
||||
queryPlan.queryPlanInit(request.thresholdMicros());
|
||||
list.add(queryPlan.createMeta(null, null));
|
||||
}
|
||||
@@ -1500,7 +1498,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* Trim query plans not used since the passed in epoch time.
|
||||
*/
|
||||
void trimQueryPlans(long unusedSince) {
|
||||
queryPlanCache.values().removeIf(queryPlan -> queryPlan.getLastQueryTime() < unusedSince);
|
||||
queryPlanCache.values().removeIf(queryPlan -> queryPlan.lastQueryTime() < unusedSince);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1893,7 +1891,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
}
|
||||
BeanPropertyAssoc<?> assocProp = (BeanPropertyAssoc<?>) other._findBeanProperty(split[0]);
|
||||
if (assocProp == null) {
|
||||
throw new IllegalStateException("Unknown property path [" + split[0] + "] from[" + path + "]");
|
||||
throw new IllegalStateException("Unknown property path " + split[0] + " from " + path);
|
||||
}
|
||||
BeanDescriptor<?> targetDesc = assocProp.targetDescriptor();
|
||||
path = split[1];
|
||||
@@ -2291,11 +2289,11 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
private ElComparator<T> createPropertyComparator(SortByClause.Property sortProp) {
|
||||
ElPropertyValue elGetValue = elGetValue(sortProp.getName());
|
||||
if (elGetValue == null) {
|
||||
log.error("Sort property [" + sortProp + "] not found in " + beanType + ". Cannot sort.");
|
||||
log.log(ERROR, "Sort property [" + sortProp + "] not found in " + beanType + ". Cannot sort.");
|
||||
return new ElComparatorNoop<>();
|
||||
}
|
||||
if (elGetValue.isAssocMany()) {
|
||||
log.error("Sort property [" + sortProp + "] in " + beanType + " is a many-property. Cannot sort.");
|
||||
log.log(ERROR, "Sort property [" + sortProp + "] in " + beanType + " is a many-property. Cannot sort.");
|
||||
return new ElComparatorNoop<>();
|
||||
}
|
||||
Boolean nullsHigh = sortProp.getNullsHigh();
|
||||
@@ -2771,7 +2769,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
public void markAsDeleted(EntityBean bean) {
|
||||
if (softDeleteProperty == null) {
|
||||
Object id = getId(bean);
|
||||
log.info("(Lazy) loading unsuccessful for type:{} id:{} - expecting when bean has been deleted", name(), id);
|
||||
log.log(INFO, "(Lazy) loading unsuccessful for type:{0} id:{1} - expecting when bean has been deleted", name(), id);
|
||||
bean._ebean_getIntercept().setLazyLoadFailure(id);
|
||||
} else {
|
||||
softDeleteValue(bean);
|
||||
@@ -3159,18 +3157,17 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
/**
|
||||
* Return true if any mutable properties are dirty.
|
||||
*/
|
||||
public boolean checkAnyMutableProperties(EntityBeanIntercept ebi) {
|
||||
public void checkAnyMutableProperties(EntityBeanIntercept ebi) {
|
||||
for (BeanProperty beanProperty : propertiesMutable) {
|
||||
int propertyIndex = beanProperty.propertyIndex();
|
||||
if (ebi.isLoadedProperty(propertyIndex)) {
|
||||
Object value = beanProperty.getValue(ebi.getOwner());
|
||||
if (beanProperty.checkMutable(value, ebi.isDirtyProperty(propertyIndex), ebi)) {
|
||||
ebi.markPropertyAsChanged(propertyIndex);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ConcurrencyMode concurrencyMode(EntityBeanIntercept ebi) {
|
||||
|
||||
+75
-76
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
@@ -13,12 +14,12 @@ import io.ebeaninternal.server.core.CacheOptions;
|
||||
import io.ebeaninternal.server.core.PersistRequest;
|
||||
import io.ebeaninternal.server.core.PersistRequestBean;
|
||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
/**
|
||||
* Helper for BeanDescriptor that manages the bean, query and collection caches.
|
||||
*
|
||||
@@ -26,12 +27,12 @@ import java.util.*;
|
||||
*/
|
||||
final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private static final Logger queryLog = LoggerFactory.getLogger("io.ebean.cache.QUERY");
|
||||
private static final Logger beanLog = LoggerFactory.getLogger("io.ebean.cache.BEAN");
|
||||
private static final Logger manyLog = LoggerFactory.getLogger("io.ebean.cache.COLL");
|
||||
private static final Logger natLog = LoggerFactory.getLogger("io.ebean.cache.NATKEY");
|
||||
private static final System.Logger queryLog = AppLog.getLogger("io.ebean.cache.QUERY");
|
||||
private static final System.Logger beanLog = AppLog.getLogger("io.ebean.cache.BEAN");
|
||||
private static final System.Logger manyLog = AppLog.getLogger("io.ebean.cache.COLL");
|
||||
private static final System.Logger natLog = AppLog.getLogger("io.ebean.cache.NATKEY");
|
||||
|
||||
private final BeanDescriptor<T> desc;
|
||||
private final SpiCacheManager cacheManager;
|
||||
@@ -104,10 +105,10 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
void deriveNotifyFlags() {
|
||||
cacheNotifyOnAll = (invalidateQueryCache || beanCache != null || queryCache != null);
|
||||
cacheNotifyOnDelete = !cacheNotifyOnAll && isNotifyOnDeletes();
|
||||
if (log.isDebugEnabled()) {
|
||||
if (log.isLoggable(DEBUG)) {
|
||||
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
|
||||
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
|
||||
log.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ",
|
||||
log.log(DEBUG, "l2 caching on {0} - beanCaching:{1} queryCaching:{2} notifyMode:{3} ",
|
||||
desc.fullName(), isBeanCaching(), isQueryCaching(), notifyMode);
|
||||
}
|
||||
}
|
||||
@@ -178,8 +179,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
*/
|
||||
void queryCacheClear() {
|
||||
if (queryCache != null) {
|
||||
if (queryLog.isDebugEnabled()) {
|
||||
queryLog.debug(" CLEAR {}", cacheName);
|
||||
if (queryLog.isLoggable(DEBUG)) {
|
||||
queryLog.log(DEBUG, " CLEAR {0}", cacheName);
|
||||
}
|
||||
queryCache.clear();
|
||||
}
|
||||
@@ -202,11 +203,11 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
||||
}
|
||||
Object queryResult = queryCache.get(id);
|
||||
if (queryLog.isDebugEnabled()) {
|
||||
if (queryLog.isLoggable(DEBUG)) {
|
||||
if (queryResult == null) {
|
||||
queryLog.debug(" GET {}({}) - cache miss", cacheName, id);
|
||||
queryLog.log(DEBUG, " GET {0}({1}) - cache miss", cacheName, id);
|
||||
} else {
|
||||
queryLog.debug(" GET {}({}) - hit", cacheName, id);
|
||||
queryLog.log(DEBUG, " GET {0}({1}) - hit", cacheName, id);
|
||||
}
|
||||
}
|
||||
return queryResult;
|
||||
@@ -219,8 +220,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
if (queryCache == null) {
|
||||
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
||||
}
|
||||
if (queryLog.isDebugEnabled()) {
|
||||
queryLog.debug(" PUT {}({})", cacheName, id);
|
||||
if (queryLog.isLoggable(DEBUG)) {
|
||||
queryLog.log(DEBUG, " PUT {0}({1})", cacheName, id);
|
||||
}
|
||||
queryCache.put(id, entry);
|
||||
}
|
||||
@@ -228,16 +229,16 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
void manyPropRemove(String propertyName, Object parentId) {
|
||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||
if (manyLog.isTraceEnabled()) {
|
||||
manyLog.trace(" REMOVE {}({}).{}", cacheName, parentId, propertyName);
|
||||
if (manyLog.isLoggable(TRACE)) {
|
||||
manyLog.log(TRACE, " REMOVE {0}({1}).{2}", cacheName, parentId, propertyName);
|
||||
}
|
||||
collectionIdsCache.remove(parentId);
|
||||
}
|
||||
|
||||
void manyPropClear(String propertyName) {
|
||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||
if (manyLog.isDebugEnabled()) {
|
||||
manyLog.debug(" CLEAR {}(*).{} ", cacheName, propertyName);
|
||||
if (manyLog.isLoggable(DEBUG)) {
|
||||
manyLog.log(DEBUG, " CLEAR {0}(*).{1} ", cacheName, propertyName);
|
||||
}
|
||||
collectionIdsCache.clear();
|
||||
}
|
||||
@@ -249,11 +250,11 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||
CachedManyIds entry = (CachedManyIds) collectionIdsCache.get(parentId);
|
||||
if (entry == null) {
|
||||
if (manyLog.isTraceEnabled()) {
|
||||
manyLog.trace(" GET {}({}).{} - cache miss", cacheName, parentId, propertyName);
|
||||
if (manyLog.isLoggable(TRACE)) {
|
||||
manyLog.log(TRACE, " GET {0}({1}).{2} - cache miss", cacheName, parentId, propertyName);
|
||||
}
|
||||
} else if (manyLog.isDebugEnabled()) {
|
||||
manyLog.debug(" GET {}({}).{} - hit", cacheName, parentId, propertyName);
|
||||
} else if (manyLog.isLoggable(DEBUG)) {
|
||||
manyLog.log(DEBUG, " GET {0}({1}).{2} - hit", cacheName, parentId, propertyName);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
@@ -303,12 +304,12 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
changes.put(many.name(), asJson);
|
||||
|
||||
CachedBeanData newData = data.update(changes, data.getVersion());
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" UPDATE {}({}) changes:{}", cacheName, parentId, changes);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " UPDATE {0}({1}) changes:{2}", cacheName, parentId, changes);
|
||||
}
|
||||
beanCache.put(parentId, newData);
|
||||
} catch (IOException e) {
|
||||
log.error("Error updating L2 cache", e);
|
||||
log.log(ERROR, "Error updating L2 cache", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -321,8 +322,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
void cachePutManyIds(Object parentId, String manyName, CachedManyIds entry) {
|
||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, manyName);
|
||||
if (manyLog.isDebugEnabled()) {
|
||||
manyLog.debug(" PUT {}({}).{} - ids:{}", cacheName, parentId, manyName, entry);
|
||||
if (manyLog.isLoggable(DEBUG)) {
|
||||
manyLog.log(DEBUG, " PUT {0}({1}).{2} - ids:{3}", cacheName, parentId, manyName, entry);
|
||||
}
|
||||
collectionIdsCache.put(parentId, entry);
|
||||
}
|
||||
@@ -353,8 +354,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
return new BeanCacheResult<>();
|
||||
}
|
||||
Map<Object, Object> beanDataMap = beanCache.getAll(keys);
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" MGET {}({}) - hits:{}", cacheName, ids, beanDataMap.keySet());
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " MGET {0}({1}) - hits:{2}", cacheName, ids, beanDataMap.keySet());
|
||||
}
|
||||
BeanCacheResult<T> result = new BeanCacheResult<>();
|
||||
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
||||
@@ -375,8 +376,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
// naturalKey -> Id map
|
||||
Map<Object, Object> naturalKeyMap = naturalKeyCache.getAll(keys);
|
||||
if (natLog.isTraceEnabled()) {
|
||||
natLog.trace(" MLOOKUP {}({}) - hits:{}", cacheName, keys, naturalKeyMap);
|
||||
if (natLog.isLoggable(TRACE)) {
|
||||
natLog.log(TRACE, " MLOOKUP {0}({1}) - hits:{2}", cacheName, keys, naturalKeyMap);
|
||||
}
|
||||
|
||||
BeanCacheResult<T> result = new BeanCacheResult<>();
|
||||
@@ -392,8 +393,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
Set<Object> ids = new HashSet<>(naturalKeyMap.values());
|
||||
Map<Object, Object> beanDataMap = beanCache.getAll(ids);
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" MGET {}({}) - hits:{}", cacheName, ids, beanDataMap.keySet());
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " MGET {0}({1}) - hits:{2}", cacheName, ids, beanDataMap.keySet());
|
||||
}
|
||||
// process the hits into beans etc
|
||||
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
||||
@@ -437,8 +438,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
*/
|
||||
void beanCacheClear() {
|
||||
if (beanCache != null) {
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" CLEAR {}", cacheName);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " CLEAR {0}", cacheName);
|
||||
}
|
||||
beanCache.clear();
|
||||
}
|
||||
@@ -507,14 +508,14 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" MPUT {}({})", cacheName, map.keySet());
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " MPUT {0}({1})", cacheName, map.keySet());
|
||||
}
|
||||
getBeanCache().putAll(map);
|
||||
|
||||
if (natKeys != null && !natKeys.isEmpty()) {
|
||||
if (natLog.isDebugEnabled()) {
|
||||
natLog.debug(" MPUT {}({}, {})", cacheName, naturalKey, natKeys.keySet());
|
||||
if (natLog.isLoggable(DEBUG)) {
|
||||
natLog.log(DEBUG, " MPUT {0}({1}, {2})", cacheName, naturalKey, natKeys.keySet());
|
||||
}
|
||||
naturalKeyCache.putAll(natKeys);
|
||||
}
|
||||
@@ -526,15 +527,15 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
void beanCachePutDirect(EntityBean bean) {
|
||||
CachedBeanData beanData = beanExtractData(desc, bean);
|
||||
String key = desc.cacheKeyForBean(bean);
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" PUT {}({}) data:{}", cacheName, key, beanData);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " PUT {0}({1}) data:{2}", cacheName, key, beanData);
|
||||
}
|
||||
getBeanCache().put(key, beanData);
|
||||
if (naturalKey != null) {
|
||||
String naturalKey = calculateNaturalKey(beanData);
|
||||
if (naturalKey != null) {
|
||||
if (natLog.isDebugEnabled()) {
|
||||
natLog.debug(" PUT {}({}, {})", cacheName, naturalKey, key);
|
||||
if (natLog.isLoggable(DEBUG)) {
|
||||
natLog.log(DEBUG, " PUT {0}({1}, {2})", cacheName, naturalKey, key);
|
||||
}
|
||||
naturalKeyCache.put(naturalKey, key);
|
||||
}
|
||||
@@ -575,13 +576,13 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
private T beanCacheGetInternal(String key, Boolean readOnly, PersistenceContext context) {
|
||||
CachedBeanData data = (CachedBeanData) getBeanCache().get(key);
|
||||
if (data == null) {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" GET {}({}) - cache miss", cacheName, key);
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " GET {0}({1}) - cache miss", cacheName, key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" GET {}({}) - hit", cacheName, key);
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " GET {0}({1}) - hit", cacheName, key);
|
||||
}
|
||||
return convertToBean(key, readOnly, context, data);
|
||||
}
|
||||
@@ -591,8 +592,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) {
|
||||
Object bean = data.getSharableBean();
|
||||
if (bean != null) {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" GET {}({}) - hit shared bean", cacheName, id);
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " GET {0}({1}) - hit shared bean", cacheName, id);
|
||||
}
|
||||
if (desc.isReadAuditing()) {
|
||||
desc.readAuditBean("l2", "", bean);
|
||||
@@ -680,8 +681,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
*/
|
||||
void beanCacheApplyInvalidate(Collection<String> keys) {
|
||||
if (beanCache != null) {
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" MREMOVE {}({})", cacheName, keys);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " MREMOVE {0}({1})", cacheName, keys);
|
||||
}
|
||||
beanCache.removeAll(new HashSet<>(keys));
|
||||
}
|
||||
@@ -700,32 +701,30 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
}
|
||||
|
||||
Map<Object, Object> hits = getBeanCache().getAll(ebis.keySet());
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" MLOAD {}({}) - got hits ({})", cacheName, ebis.keySet(), hits.size());
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " MLOAD {0}({1}) - got hits ({2})", cacheName, ebis.keySet(), hits.size());
|
||||
}
|
||||
|
||||
Set<EntityBeanIntercept> loaded = new HashSet<>();
|
||||
Iterator<Map.Entry<Object, Object>> iterator = hits.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Object, Object> hit = iterator.next();
|
||||
for (Map.Entry<Object, Object> hit : hits.entrySet()) {
|
||||
Object key = hit.getKey();
|
||||
EntityBeanIntercept ebi = ebis.remove(key);
|
||||
CachedBeanData cacheData = (CachedBeanData) hit.getValue();
|
||||
|
||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(propertyName)) {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" load {}({}) - cache miss on property({})", cacheName, key, propertyName);
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " load {0}({1}) - cache miss on property({2})", cacheName, key, propertyName);
|
||||
}
|
||||
} else {
|
||||
CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context);
|
||||
loaded.add(ebi);
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" load {}({}) - hit", cacheName, key);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " load {0}({1}) - hit", cacheName, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ebis.isEmpty() && beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" load {}({}) - cache miss", cacheName, ebis.keySet());
|
||||
if (!ebis.isEmpty() && beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " load {0}({1}) - cache miss", cacheName, ebis.keySet());
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
@@ -736,21 +735,21 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
boolean beanCacheLoad(EntityBean bean, EntityBeanIntercept ebi, String key, PersistenceContext context) {
|
||||
CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(key);
|
||||
if (cacheData == null) {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" LOAD {}({}) - cache miss", cacheName, key);
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " LOAD {0}({1}) - cache miss", cacheName, key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
|
||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.getLazyLoadProperty())) {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" LOAD {}({}) - cache miss on property({})", cacheName, key, ebi.getLazyLoadProperty());
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " LOAD {0}({1}) - cache miss on property({2})", cacheName, key, ebi.getLazyLoadProperty());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
CachedBeanDataToBean.load(desc, bean, cacheData, context);
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" LOAD {}({}) - hit", cacheName, key);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " LOAD {0}({1}) - hit", cacheName, key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -874,8 +873,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
if (existingData != null) {
|
||||
long currentVersion = existingData.getVersion();
|
||||
if (version > 0 && version < currentVersion) {
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" REMOVE {}({}) - version conflict old:{} new:{}", cacheName, key, currentVersion, version);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " REMOVE {0}({1}) - version conflict old:{2} new:{3}", cacheName, key, currentVersion, version);
|
||||
}
|
||||
cache.remove(key);
|
||||
} else {
|
||||
@@ -883,16 +882,16 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
version = currentVersion;
|
||||
}
|
||||
CachedBeanData newData = existingData.update(changes, version);
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
beanLog.debug(" UPDATE {}({}) changes:{}", cacheName, key, changes);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " UPDATE {0}({1}) changes:{2}", cacheName, key, changes);
|
||||
}
|
||||
cache.put(key, newData);
|
||||
}
|
||||
if (updateNaturalKey) {
|
||||
Object oldKey = calculateNaturalKey(existingData);
|
||||
if (oldKey != null) {
|
||||
if (natLog.isDebugEnabled()) {
|
||||
natLog.debug(".. update {} REMOVE({}) - old key for ({})", cacheName, oldKey, key);
|
||||
if (natLog.isLoggable(DEBUG)) {
|
||||
natLog.log(DEBUG, ".. update {0} REMOVE({1}) - old key for ({2})", cacheName, oldKey, key);
|
||||
}
|
||||
naturalKeyCache.remove(oldKey);
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
|
||||
BeanDescriptorElementEmbeddedMap(BeanDescriptorMap owner, DeployBeanDescriptor<T> deploy, ElementHelp elementHelp) {
|
||||
super(owner, deploy, elementHelp);
|
||||
this.scalarTypeKey = firstBaseScalarType();
|
||||
this.stringKey = String.class.equals(scalarTypeKey.getType());
|
||||
this.stringKey = String.class.equals(scalarTypeKey.type());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +49,7 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
|
||||
|
||||
@Override
|
||||
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
JsonParser parser = readJson.getParser();
|
||||
JsonParser parser = readJson.parser();
|
||||
ElementCollector add = elementHelp.createCollector();
|
||||
do {
|
||||
String fieldName = parser.nextFieldName();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ class BeanDescriptorElementScalar<T> extends BeanDescriptorElement<T> {
|
||||
|
||||
@Override
|
||||
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
JsonParser parser = readJson.getParser();
|
||||
JsonParser parser = readJson.parser();
|
||||
ElementCollector add = elementHelp.createCollector();
|
||||
do {
|
||||
JsonToken token = parser.nextToken();
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
|
||||
}
|
||||
this.scalarTypeKey = props[0].scalarType();
|
||||
this.scalarTypeVal = props[1].scalarType();
|
||||
this.stringKey = String.class.equals(scalarTypeKey.getType());
|
||||
this.stringKey = String.class.equals(scalarTypeKey.type());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +49,7 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
|
||||
|
||||
@Override
|
||||
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
JsonParser parser = readJson.getParser();
|
||||
JsonParser parser = readJson.parser();
|
||||
ElementCollector add = elementHelp.createCollector();
|
||||
do {
|
||||
String fieldName = parser.nextFieldName();
|
||||
|
||||
@@ -66,7 +66,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance, T target) throws IOException {
|
||||
JsonParser parser = jsonRead.getParser();
|
||||
JsonParser parser = jsonRead.parser();
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
|
||||
// start object token read by Jackson already
|
||||
@@ -85,7 +85,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
return jsonReadObject(jsonRead, path, target);
|
||||
}
|
||||
|
||||
ObjectNode node = jsonRead.getObjectMapper().readTree(parser);
|
||||
ObjectNode node = jsonRead.mapper().readTree(parser);
|
||||
if (node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
// unmapped properties, send to JsonReadBeanVisitor later
|
||||
Map<String, Object> unmappedProperties = null;
|
||||
do {
|
||||
JsonParser parser = readJson.getParser();
|
||||
JsonParser parser = readJson.parser();
|
||||
JsonToken event = parser.nextToken();
|
||||
if (JsonToken.FIELD_NAME == event) {
|
||||
String key = parser.getCurrentName();
|
||||
|
||||
+28
-32
@@ -41,7 +41,6 @@ import io.ebeaninternal.xmapping.api.XmapNamedQuery;
|
||||
import io.ebeaninternal.xmapping.api.XmapRawSql;
|
||||
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||
import io.ebeanservice.docstore.api.DocStoreFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.PersistenceException;
|
||||
@@ -53,12 +52,14 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
/**
|
||||
* Creates BeanDescriptors.
|
||||
*/
|
||||
public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTypeManager {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private static final BeanDescComparator beanDescComparator = new BeanDescComparator();
|
||||
public static final String JAVA_LANG_RECORD = "java.lang.Record";
|
||||
@@ -133,7 +134,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
this.encryptKeyManager = this.config.getEncryptKeyManager();
|
||||
this.databasePlatform = this.config.getDatabasePlatform();
|
||||
this.multiValueBind = config.getMultiValueBind();
|
||||
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
|
||||
this.idBinderFactory = new IdBinderFactory(databasePlatform.idInExpandedForm(), multiValueBind);
|
||||
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
|
||||
this.asOfViewSuffix = asOfViewSuffix(databasePlatform, this.config);
|
||||
String versionsBetweenSuffix = versionsBetweenSuffix(databasePlatform, this.config);
|
||||
@@ -141,10 +142,10 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
this.bootupClasses = config.getBootupClasses();
|
||||
this.createProperties = config.getDeployCreateProperties();
|
||||
this.namingConvention = this.config.getNamingConvention();
|
||||
this.dbIdentity = config.getDatabasePlatform().getDbIdentity();
|
||||
this.dbIdentity = config.getDatabasePlatform().dbIdentity();
|
||||
this.deplyInherit = config.getDeployInherit();
|
||||
this.deployUtil = config.getDeployUtil();
|
||||
this.typeManager = deployUtil.getTypeManager();
|
||||
this.typeManager = deployUtil.typeManager();
|
||||
this.beanManagerFactory = new BeanManagerFactory(config.getDatabasePlatform());
|
||||
this.beanLifecycleAdapterFactory = new BeanLifecycleAdapterFactory(this.config);
|
||||
this.persistControllerManager = new PersistControllerManager(bootupClasses);
|
||||
@@ -183,19 +184,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
|
||||
@Override
|
||||
public ScalarType<?> scalarType(String cast) {
|
||||
return typeManager.getScalarType(cast);
|
||||
return typeManager.type(cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarType<?> scalarType(int jdbcType) {
|
||||
return typeManager.getScalarType(jdbcType);
|
||||
return typeManager.type(jdbcType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the AsOfViewSuffix based on the DbHistorySupport.
|
||||
*/
|
||||
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||
DbHistorySupport historySupport = databasePlatform.historySupport();
|
||||
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
|
||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
|
||||
}
|
||||
@@ -204,7 +205,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* Return the versions between timestamp suffix based on the DbHistorySupport.
|
||||
*/
|
||||
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||
DbHistorySupport historySupport = databasePlatform.historySupport();
|
||||
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
|
||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
|
||||
}
|
||||
@@ -309,7 +310,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
} catch (BeanNotEnhancedException e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
log.error("Error in deployment", e);
|
||||
log.log(ERROR, "Error in deployment", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -332,13 +333,13 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
try {
|
||||
entityClass = Class.forName(entityClassName, false, classLoader);
|
||||
} catch (Exception e) {
|
||||
log.error("Could not load entity bean class " + entityClassName + " for ebean.xml entry");
|
||||
log.log(ERROR, "Could not load entity bean class " + entityClassName + " for ebean.xml entry");
|
||||
return;
|
||||
}
|
||||
|
||||
DeployBeanInfo<?> info = deployInfoMap.get(entityClass);
|
||||
if (info == null) {
|
||||
log.error("No entity bean for ebean.xml entry " + entityClassName);
|
||||
log.log(ERROR, "No entity bean for ebean.xml entry " + entityClassName);
|
||||
|
||||
} else {
|
||||
for (XmapRawSql sql : entityDeploy.getRawSql()) {
|
||||
@@ -601,11 +602,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
int pc = postConstructManager.getRegisterCount();
|
||||
int lc = persistListenerManager.getRegisterCount();
|
||||
int fc = beanFinderManager.getRegisterCount();
|
||||
log.debug("BeanPersistControllers[{}] BeanFinders[{}] BeanPersistListeners[{}] BeanQueryAdapters[{}] BeanPostLoaders[{}] BeanPostConstructors[{}]", cc, fc, lc, qa, pl, pc);
|
||||
log.log(DEBUG, "BeanPersistControllers[{0}] BeanFinders[{1}] BeanPersistListeners[{2}] BeanQueryAdapters[{3}] BeanPostLoaders[{4}] BeanPostConstructors[{5}]", cc, fc, lc, qa, pl, pc);
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
log.debug("Entities[{}]", entityBeanCount);
|
||||
log.log(DEBUG, "Entities[{0}]", entityBeanCount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -865,13 +866,8 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
for (String possibleMappedBy : matchSet) {
|
||||
String possibleLower = possibleMappedBy.toLowerCase();
|
||||
if (possibleLower.contains(searchName)) {
|
||||
// we have a match..
|
||||
// we have a match
|
||||
prop.setMappedBy(possibleMappedBy);
|
||||
|
||||
String m = "Implicitly found mappedBy for " + targetDesc + "." + prop;
|
||||
m += " by searching for [" + searchName + "] against " + matchSet;
|
||||
log.debug(m);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -888,7 +884,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
|
||||
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
|
||||
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
|
||||
final ScalarType<?> scalarType = typeManager.type(Integer.class);
|
||||
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, scalarType, null);
|
||||
orderProperty.setName(DeployOrderColumn.LOGICAL_NAME);
|
||||
orderProperty.setDbColumn(orderColumn.getName());
|
||||
@@ -987,14 +983,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
private DeployBeanPropertyAssocOne<?> mappedOneToOne(DeployBeanPropertyAssocOne<?> prop, String mappedBy, DeployBeanDescriptor<?> targetDesc) {
|
||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||
if (mappedProp == null) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property [" + targetDesc + "." + mappedBy + "]");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + targetDesc + "." + mappedBy);
|
||||
}
|
||||
if (!(mappedProp instanceof DeployBeanPropertyAssocOne<?>)) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property [" + targetDesc + "." + mappedBy + "]is not a OneToOne?");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?");
|
||||
}
|
||||
DeployBeanPropertyAssocOne<?> mappedAssocOne = (DeployBeanPropertyAssocOne<?>) mappedProp;
|
||||
if (!mappedAssocOne.isOneToOne()) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property [" + targetDesc + "." + mappedBy + "]is not a OneToOne?");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?");
|
||||
}
|
||||
return mappedAssocOne;
|
||||
}
|
||||
@@ -1077,10 +1073,10 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
private DeployBeanPropertyAssocOne<?> mappedManyToOne(DeployBeanPropertyAssocMany<?> prop, DeployBeanDescriptor<?> targetDesc, String mappedBy) {
|
||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||
if (mappedProp == null) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property [" + mappedBy + "] " + "in [" + targetDesc + "]");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + mappedBy + " in " + targetDesc);
|
||||
}
|
||||
if (!(mappedProp instanceof DeployBeanPropertyAssocOne<?>)) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property [" + mappedBy + "]is not a ManyToOne?" + "in [" + targetDesc + "]");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + mappedBy + " is not a ManyToOne? in " + targetDesc);
|
||||
}
|
||||
return (DeployBeanPropertyAssocOne<?>) mappedProp;
|
||||
}
|
||||
@@ -1128,15 +1124,15 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
private DeployBeanPropertyAssocMany<?> mappedManyToMany(DeployBeanPropertyAssocMany<?> prop, String mappedBy, DeployBeanDescriptor<?> targetDesc) {
|
||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||
if (mappedProp == null) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property [" + mappedBy + "] " + "in [" + targetDesc + "]");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + mappedBy + " in " + targetDesc);
|
||||
}
|
||||
if (!(mappedProp instanceof DeployBeanPropertyAssocMany<?>)) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property [" + targetDesc + "." + mappedBy + "] is not a ManyToMany?");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?");
|
||||
}
|
||||
|
||||
DeployBeanPropertyAssocMany<?> mappedAssocMany = (DeployBeanPropertyAssocMany<?>) mappedProp;
|
||||
if (!mappedAssocMany.isManyToMany()) {
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property [" + targetDesc + "." + mappedBy + "] is not a ManyToMany?");
|
||||
throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?");
|
||||
}
|
||||
return mappedAssocMany;
|
||||
}
|
||||
@@ -1207,12 +1203,12 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
final DeployIdentityMode identityMode = desc.getIdentityMode();
|
||||
if (identityMode.isSequence() && !dbIdentity.isSupportsSequence()) {
|
||||
// explicit sequence but not supported by the DatabasePlatform
|
||||
log.info("Explicit sequence on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
||||
log.log(INFO, "Explicit sequence on {0} but not supported by DB Platform - ignored", desc.getFullName());
|
||||
identityMode.setIdType(IdType.AUTO);
|
||||
}
|
||||
if (identityMode.isIdentity() && !dbIdentity.isSupportsIdentity()) {
|
||||
// explicit identity but not supported by the DatabasePlatform
|
||||
log.info("Explicit Identity on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
||||
log.log(INFO, "Explicit Identity on {0} but not supported by DB Platform - ignored", desc.getFullName());
|
||||
identityMode.setIdType(IdType.AUTO);
|
||||
}
|
||||
|
||||
@@ -1250,7 +1246,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
String primaryKeyColumn = desc.getSinglePrimaryKeyColumn();
|
||||
seqName = namingConvention.getSequenceName(desc.getBaseTable(), primaryKeyColumn);
|
||||
}
|
||||
int stepSize = desc.setIdentitySequenceBatchMode(databasePlatform.isSequenceBatchMode());
|
||||
int stepSize = desc.setIdentitySequenceBatchMode(databasePlatform.sequenceBatchMode());
|
||||
desc.setIdGenerator(createSequenceIdGenerator(seqName, stepSize));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,17 @@ import io.ebean.event.BeanFindController;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Default implementation for BeanFinderFactory.
|
||||
*/
|
||||
final class BeanFinderManager {
|
||||
|
||||
private static final Logger log = CoreLog.internal;
|
||||
private static final System.Logger log = CoreLog.internal;
|
||||
|
||||
private final List<BeanFindController> list;
|
||||
|
||||
@@ -31,7 +32,7 @@ final class BeanFinderManager {
|
||||
void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanFindController c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
log.debug("BeanFindController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
log.log(DEBUG, "BeanFindController on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||
deployDesc.setBeanFinder(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,11 +180,6 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int jdbcType() {
|
||||
return 0;
|
||||
@@ -195,11 +190,6 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parseDateTime(long systemTimeMillis) {
|
||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParser stringParser() {
|
||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.ebeaninternal.api.json.SpiJsonReader;
|
||||
import io.ebeaninternal.api.json.SpiJsonWriter;
|
||||
import io.ebeaninternal.server.core.EncryptAlias;
|
||||
import io.ebeaninternal.server.core.InternString;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
|
||||
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedWhenCreated;
|
||||
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedWhenModified;
|
||||
@@ -51,6 +52,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Description of a property of a bean. Includes its deployment information such
|
||||
* as database column mapping information.
|
||||
@@ -414,7 +417,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return true if the underlying type is mutable.
|
||||
*/
|
||||
public boolean isMutableScalarType() {
|
||||
return scalarType != null && scalarType.isMutable();
|
||||
return scalarType != null && scalarType.mutable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +458,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
if (formula && sqlFormulaJoin != null) {
|
||||
ctx.appendFormulaJoin(sqlFormulaJoin, joinType, manyWhere);
|
||||
} else if (secondaryTableJoin != null) {
|
||||
String relativePrefix = ctx.getRelativePrefix(secondaryTableJoinPrefix);
|
||||
String relativePrefix = ctx.relativePrefix(secondaryTableJoinPrefix);
|
||||
secondaryTableJoin.addJoin(joinType, relativePrefix, ctx);
|
||||
}
|
||||
}
|
||||
@@ -481,7 +484,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
ctx.appendFormulaSelect(sqlFormulaSelect);
|
||||
} else if (!isTransient && !ignoreDraftOnlyProperty(ctx.isDraftQuery())) {
|
||||
if (secondaryTableJoin != null) {
|
||||
ctx.pushTableAlias(ctx.getRelativePrefix(secondaryTableJoinPrefix));
|
||||
ctx.pushTableAlias(ctx.relativePrefix(secondaryTableJoinPrefix));
|
||||
}
|
||||
if (dbEncrypted) {
|
||||
ctx.appendRawColumn(decryptSqlWithColumnAlias(ctx.peekTableAlias()));
|
||||
@@ -506,7 +509,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
|
||||
@Override
|
||||
public void loadIgnore(DbReadContext ctx) {
|
||||
scalarType.loadIgnore(ctx.getDataReader());
|
||||
ctx.dataReader().incrementPos(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,11 +544,11 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
public Object read(DbReadContext ctx) throws SQLException {
|
||||
return scalarType.read(ctx.getDataReader());
|
||||
return scalarType.read(ctx.dataReader());
|
||||
}
|
||||
|
||||
public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException {
|
||||
return readSet(ctx.getDataReader(), bean);
|
||||
return readSet(ctx.dataReader(), bean);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -701,7 +704,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
private Object cacheDataConvert(Object value) {
|
||||
if (value == null || scalarType.isBinaryType()) {
|
||||
if (value == null || scalarType.binary()) {
|
||||
return value;
|
||||
} else {
|
||||
// convert to string as an optimisation for java object serialisation
|
||||
@@ -924,6 +927,10 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return alreadyDirty || value != null && scalarType.isDirty(value);
|
||||
}
|
||||
|
||||
public boolean isArrayType() {
|
||||
return scalarType instanceof ScalarTypeArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scalarType.
|
||||
*/
|
||||
@@ -938,19 +945,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return scalarType != null && scalarType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int jdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parseDateTime(long systemTimeMillis) {
|
||||
return scalarType.convertFromMillis(systemTimeMillis);
|
||||
return scalarType == null ? 0 : scalarType.jdbcType();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1414,7 +1411,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
JsonToken event = ctx.nextToken();
|
||||
if (JsonToken.VALUE_NULL == event) {
|
||||
if (jsonDeserialize) {
|
||||
if (ctx.isIntercept()) {
|
||||
if (ctx.intercept()) {
|
||||
setValueIntercept(bean, null);
|
||||
} else {
|
||||
setValue(bean, null);
|
||||
@@ -1424,7 +1421,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
// expect to read non-null json value
|
||||
Object objValue;
|
||||
if (scalarType != null) {
|
||||
objValue = scalarType.jsonRead(ctx.getParser());
|
||||
objValue = scalarType.jsonRead(ctx.parser());
|
||||
} else {
|
||||
try {
|
||||
objValue = ctx.readValueUsingObjectMapper(propertyType);
|
||||
@@ -1433,11 +1430,11 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
objValue = null;
|
||||
String msg = "Error trying to use Jackson ObjectMapper to read transient property "
|
||||
+ fullName() + " - consider marking this property with @JsonIgnore";
|
||||
CoreLog.log.error(msg, e);
|
||||
CoreLog.log.log(ERROR, msg, e);
|
||||
}
|
||||
}
|
||||
if (jsonDeserialize) {
|
||||
if (ctx.isIntercept()) {
|
||||
if (ctx.intercept()) {
|
||||
setValueIntercept(bean, objValue);
|
||||
} else {
|
||||
setValue(bean, objValue);
|
||||
@@ -1470,7 +1467,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*/
|
||||
public void docStoreMapping(DocMappingBuilder mapping, String prefix) {
|
||||
if (mapping.includesProperty(prefix, name)) {
|
||||
DocPropertyType type = scalarType.getDocType();
|
||||
DocPropertyType type = scalarType.docType();
|
||||
DocPropertyOptions options = docOptions.copy();
|
||||
if (isKeywordType(type, options)) {
|
||||
type = DocPropertyType.KEYWORD;
|
||||
|
||||
@@ -30,6 +30,8 @@ import javax.persistence.PersistenceException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Abstract base for properties mapped to an associated bean, list, set or map.
|
||||
*/
|
||||
@@ -353,7 +355,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
mapping.push(nested);
|
||||
targetDescriptor.docStoreMapping(mapping, fullName);
|
||||
mapping.pop();
|
||||
if (!nested.getChildren().isEmpty()) {
|
||||
if (!nested.children().isEmpty()) {
|
||||
mapping.add(nested);
|
||||
}
|
||||
}
|
||||
@@ -364,7 +366,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
*/
|
||||
public boolean isUpdateable() {
|
||||
TableJoinColumn[] columns = tableJoin.columns();
|
||||
if (columns.length <= 0) {
|
||||
if (columns.length == 0) {
|
||||
return true;
|
||||
}
|
||||
for (TableJoinColumn column : columns) {
|
||||
@@ -381,7 +383,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
*/
|
||||
public boolean isInsertable() {
|
||||
TableJoinColumn[] columns = tableJoin.columns();
|
||||
if (columns.length <= 0) {
|
||||
if (columns.length == 0) {
|
||||
return true;
|
||||
}
|
||||
for (TableJoinColumn column : columns) {
|
||||
@@ -432,7 +434,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
if (!idProp.isEmbedded()) {
|
||||
// simple single scalar id
|
||||
if (cols.length != 1) {
|
||||
CoreLog.log.error("No Imported Id column for [" + idProp + "] in table [" + join.getTable() + "]");
|
||||
CoreLog.log.log(ERROR, "No Imported Id column for {0} in table {1}", idProp, join.getTable());
|
||||
return null;
|
||||
} else {
|
||||
BeanProperty[] idProps = {idProp};
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
|
||||
/**
|
||||
* Property mapped to a List Set or Map.
|
||||
*/
|
||||
@@ -326,7 +328,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
@Override
|
||||
public void lazyLoadMany(EntityBean current) {
|
||||
EntityBean parentBean = childMasterProperty.getValueAsEntityBean(current);
|
||||
EntityBean parentBean = childMasterProperty.valueAsEntityBean(current);
|
||||
if (parentBean != null) {
|
||||
addBeanToCollectionWithCreate(parentBean, current, true);
|
||||
}
|
||||
@@ -667,7 +669,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
// not found as individual scalar properties
|
||||
CoreLog.log.error("Could not find a exported property?", e);
|
||||
CoreLog.log.log(ERROR, "Could not find a exported property?", e);
|
||||
}
|
||||
} else {
|
||||
if (idProp != null) {
|
||||
@@ -716,7 +718,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Can not find Master [" + beanType + "] in Child[" + targetDesc + "]");
|
||||
throw new RuntimeException("Can not find Master " + beanType + " in Child " + targetDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -732,7 +734,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
String from = descriptor.fullName();
|
||||
String to = targetDesc.fullName();
|
||||
throw new PersistenceException(from + ": Could not find mapKey property [" + mapKey + "] on [" + to + "]");
|
||||
throw new PersistenceException(from + ": Could not find mapKey property " + mapKey + " on " + to);
|
||||
}
|
||||
|
||||
public IntersectionRow buildManyDeleteChildren(EntityBean parentBean, List<Object> excludeDetailIds) {
|
||||
@@ -962,7 +964,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
setValue(bean, collection);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CoreLog.log.error("Error setting value from L2 cache", e);
|
||||
CoreLog.log.log(ERROR, "Error setting value from L2 cache", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -975,7 +977,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
return jsonWriteCollection(collection);
|
||||
} catch (Exception e) {
|
||||
CoreLog.log.error("Error building value element collection json for L2 cache", e);
|
||||
CoreLog.log.log(ERROR, "Error building value element collection json for L2 cache", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -996,7 +998,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
private Object jsonReadCollection(String json) throws IOException {
|
||||
SpiJsonReader ctx = descriptor.createJsonReader(json);
|
||||
JsonParser parser = ctx.getParser();
|
||||
JsonParser parser = ctx.parser();
|
||||
JsonToken event = parser.nextToken();
|
||||
if (JsonToken.VALUE_NULL == event) {
|
||||
return null;
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ class BeanPropertyAssocManyJsonHelp {
|
||||
if (!this.many.jsonDeserialize) {
|
||||
return;
|
||||
}
|
||||
JsonParser parser = readJson.getParser();
|
||||
JsonParser parser = readJson.parser();
|
||||
JsonToken event = parser.nextToken();
|
||||
if (JsonToken.VALUE_NULL == event) {
|
||||
return;
|
||||
@@ -50,7 +50,7 @@ class BeanPropertyAssocManyJsonHelp {
|
||||
if (JsonToken.START_ARRAY != event && JsonToken.START_OBJECT != event) {
|
||||
throw new JsonParseException(parser, "Unexpected token " + event + " - expecting start array or object");
|
||||
}
|
||||
if (readJson.isIntercept()) {
|
||||
if (readJson.intercept()) {
|
||||
many.setValueIntercept(parentBean, many.jsonReadCollection(readJson, parentBean));
|
||||
} else {
|
||||
many.setValue(parentBean, many.jsonReadCollection(readJson, parentBean));
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ class BeanPropertyAssocManyJsonTransient {
|
||||
* Use Jackson ObjectMapper to read the transient 'many' property.
|
||||
*/
|
||||
void jsonReadUsingObjectMapper(BeanPropertyAssocMany<?> many, SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
ObjectMapper mapper = readJson.getObjectMapper();
|
||||
ObjectMapper mapper = readJson.mapper();
|
||||
ManyType manyType = many.manyType();
|
||||
|
||||
Object value;
|
||||
@@ -29,11 +29,11 @@ class BeanPropertyAssocManyJsonTransient {
|
||||
TypeFactory typeFactory = mapper.getTypeFactory();
|
||||
JavaType target = typeFactory.constructType(many.targetType());
|
||||
MapType jacksonType = typeFactory.constructMapType(LinkedHashMap.class, TypeFactory.unknownType(), target);
|
||||
value = mapper.readValue(readJson.getParser(), jacksonType);
|
||||
value = mapper.readValue(readJson.parser(), jacksonType);
|
||||
} else {
|
||||
// read list or set using Jackson object mapper
|
||||
CollectionType jacksonType = mapper.getTypeFactory().constructCollectionType(manyType.getCollectionType(), many.targetType());
|
||||
value = mapper.readValue(readJson.getParser(), jacksonType);
|
||||
value = mapper.readValue(readJson.parser(), jacksonType);
|
||||
}
|
||||
many.setValue(parentBean, value);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* Return the property value as an entity bean.
|
||||
*/
|
||||
@Override
|
||||
public EntityBean getValueAsEntityBean(EntityBean owner) {
|
||||
public EntityBean valueAsEntityBean(EntityBean owner) {
|
||||
return (EntityBean) getValue(owner);
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
if (value == null) {
|
||||
writeJson.writeNullField(name);
|
||||
} else {
|
||||
if (!writeJson.isParentBean(value)) {
|
||||
if (!writeJson.parentBean(value)) {
|
||||
// Hmmm, not writing complex non-entity bean
|
||||
if (value instanceof EntityBean) {
|
||||
writeJson.beginAssocOne(name, bean);
|
||||
@@ -780,12 +780,13 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException {
|
||||
if (jsonDeserialize && targetDescriptor != null) {
|
||||
T target = (T) value(bean);
|
||||
T assocBean = targetDescriptor.jsonRead(readJson, name, target);
|
||||
if (readJson.isIntercept()) {
|
||||
if (readJson.intercept()) {
|
||||
setValueIntercept(bean, assocBean);
|
||||
} else {
|
||||
setValue(bean, assocBean);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
|
||||
/**
|
||||
* Bean property for synthetic sort order value / order column.
|
||||
*
|
||||
* <p>
|
||||
* The value of which is held on the entity bean intercept.
|
||||
*/
|
||||
public final class BeanPropertyOrderColumn extends BeanProperty {
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
@@ -28,7 +30,7 @@ final class BeanQueryAdapterManager {
|
||||
void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanQueryAdapter c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
CoreLog.internal.debug("BeanQueryAdapter on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
CoreLog.internal.log(DEBUG, "BeanQueryAdapter on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||
deployDesc.addQueryAdapter(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.server.core.InternString;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanTable;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployTableJoin;
|
||||
@@ -105,7 +104,6 @@ public final class BeanTable {
|
||||
if (complexKey) {
|
||||
// just to copy the column name rather than prefix with the foreignKeyPrefix.
|
||||
// I think that with complex keys this is the more common approach.
|
||||
CoreLog.internal.debug("On table[{}] foreign key column [{}]", baseTable, lc);
|
||||
fk = lc;
|
||||
}
|
||||
if (sqlFormulaSelect != null) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,7 +29,7 @@ public final class DbMigrationInfo {
|
||||
if (scripts.length == 0) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return Collections.unmodifiableList(Arrays.asList(scripts));
|
||||
return List.of(scripts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the DataReader.
|
||||
*/
|
||||
DataReader getDataReader();
|
||||
DataReader dataReader();
|
||||
|
||||
/**
|
||||
* Return true if the query is using supplied SQL rather than generated SQL.
|
||||
@@ -52,7 +52,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the persistence context.
|
||||
*/
|
||||
PersistenceContext getPersistenceContext();
|
||||
PersistenceContext persistenceContext();
|
||||
|
||||
/**
|
||||
* Register a reference for lazy loading.
|
||||
@@ -69,7 +69,6 @@ public interface DbReadContext {
|
||||
*/
|
||||
void register(BeanPropertyAssocMany<?> many, BeanCollection<?> bc);
|
||||
|
||||
|
||||
/**
|
||||
* Set back the bean that has just been loaded with its id.
|
||||
*/
|
||||
@@ -78,7 +77,7 @@ public interface DbReadContext {
|
||||
/**
|
||||
* Return the query mode.
|
||||
*/
|
||||
SpiQuery.Mode getQueryMode();
|
||||
SpiQuery.Mode queryMode();
|
||||
|
||||
/**
|
||||
* Return true if the underlying query is a 'asDraft' query.
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface DbSqlContext {
|
||||
/**
|
||||
* Return a list of encrypted properties which require additional binding.
|
||||
*/
|
||||
BeanProperty[] getEncryptedProps();
|
||||
BeanProperty[] encryptedProps();
|
||||
|
||||
/**
|
||||
* Append a string directly to the SQL buffer.
|
||||
@@ -83,7 +83,7 @@ public interface DbSqlContext {
|
||||
/**
|
||||
* Return the current context of the sql context.
|
||||
*/
|
||||
String getContent();
|
||||
String content();
|
||||
|
||||
/**
|
||||
* Push a join node onto the stack.
|
||||
@@ -99,14 +99,14 @@ public interface DbSqlContext {
|
||||
* Return a table alias without many where clause joins. Typically this is for
|
||||
* the select clause (fetch joins).
|
||||
*/
|
||||
String getTableAlias(String prefix);
|
||||
String tableAlias(String prefix);
|
||||
|
||||
/**
|
||||
* Return a table alias that takes into account many where joins.
|
||||
*/
|
||||
String getTableAliasManyWhere(String prefix);
|
||||
String tableAliasManyWhere(String prefix);
|
||||
|
||||
String getRelativePrefix(String propName);
|
||||
String relativePrefix(String propName);
|
||||
|
||||
/**
|
||||
* Append the lower and upper bound columns into the select clause
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@ public final class DeployDocPropertyOptions {
|
||||
*/
|
||||
public void setDocSortable(DocSortable doc) {
|
||||
createOptions();
|
||||
mapping.setSortable(true);
|
||||
mapping.sortable(true);
|
||||
setStore(doc.store());
|
||||
setBoost(doc.boost());
|
||||
setNullValue(doc.nullValue());
|
||||
@@ -44,7 +44,7 @@ public final class DeployDocPropertyOptions {
|
||||
*/
|
||||
public void setDocCode(DocCode doc) {
|
||||
createOptions();
|
||||
mapping.setCode(true);
|
||||
mapping.code(true);
|
||||
setStore(doc.store());
|
||||
setBoost(doc.boost());
|
||||
setNullValue(doc.nullValue());
|
||||
@@ -52,19 +52,19 @@ public final class DeployDocPropertyOptions {
|
||||
|
||||
private void setNullValue(String value) {
|
||||
if (!value.isEmpty()) {
|
||||
mapping.setNullValue(value);
|
||||
mapping.nullValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBoost(float boost) {
|
||||
if (Float.compare(boost, 1.0F) != 0) {
|
||||
mapping.setBoost(boost);
|
||||
mapping.boost(boost);
|
||||
}
|
||||
}
|
||||
|
||||
private void setStore(boolean store) {
|
||||
if (store) {
|
||||
mapping.setStore(true);
|
||||
mapping.store(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ final class DetermineAggPath {
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Could not find path in aggregation formula [" + aggregation + "]");
|
||||
throw new IllegalArgumentException("Could not find path in aggregation formula " + aggregation);
|
||||
}
|
||||
|
||||
private static boolean isNamePart(char ch) {
|
||||
@@ -94,7 +94,7 @@ final class DetermineAggPath {
|
||||
pos = pos + 1;
|
||||
continue;
|
||||
}
|
||||
throw new IllegalArgumentException("Can not find path to many in aggregation formula [" + aggregation + "]");
|
||||
throw new IllegalArgumentException("Can not find path to many in aggregation formula " + aggregation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DynamicPropertyFormula[" + parsedFormula + "]";
|
||||
return "DynamicPropertyFormula " + parsedFormula;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +47,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
|
||||
public void load(SqlBeanLoad sqlBeanLoad) {
|
||||
Object value;
|
||||
try {
|
||||
value = scalarType.read(sqlBeanLoad.ctx().getDataReader());
|
||||
value = scalarType.read(sqlBeanLoad.ctx().dataReader());
|
||||
} catch (Exception e) {
|
||||
sqlBeanLoad.ctx().handleLoadError(fullName, e);
|
||||
return;
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class DynamicPropertyBase implements STreeProperty {
|
||||
|
||||
@Override
|
||||
public void loadIgnore(DbReadContext ctx) {
|
||||
scalarType.loadIgnore(ctx.getDataReader());
|
||||
ctx.dataReader().incrementPos(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,7 @@ final class FormulaPropertyPath {
|
||||
int openBracket = formula.indexOf('(');
|
||||
int closeBracket = formula.lastIndexOf(')');
|
||||
if (openBracket == -1 || closeBracket == -1) {
|
||||
throw new IllegalStateException("Unable to parse formula [" + formula + "]");
|
||||
throw new IllegalStateException("Unable to parse formula " + formula);
|
||||
}
|
||||
outerFunction = formula.substring(0, openBracket).trim();
|
||||
internalExpression = trimDistinct(formula.substring(openBracket + 1, closeBracket));
|
||||
|
||||
@@ -197,7 +197,7 @@ public final class InheritInfo {
|
||||
* Return the associated InheritInfo for this DB row read.
|
||||
*/
|
||||
public InheritInfo readType(DbReadContext ctx) throws SQLException {
|
||||
return readType(ctx.getDataReader().getString());
|
||||
return readType(ctx.dataReader().getString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,7 +354,7 @@ public final class InheritInfo {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InheritInfo[" + type.getName() + "] disc[" + discriminatorStringValue + "]";
|
||||
return "InheritInfo " + type.getName() + " disc:" + discriminatorStringValue;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
@@ -28,7 +30,7 @@ final class PersistControllerManager {
|
||||
void addPersistControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanPersistController c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
CoreLog.log.debug("BeanPersistController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
CoreLog.log.log(DEBUG, "BeanPersistController on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||
deployDesc.addPersistController(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Manages the assignment/registration of BeanPersistListener with their
|
||||
* respective DeployBeanDescriptor's.
|
||||
@@ -29,7 +31,7 @@ final class PersistListenerManager {
|
||||
<T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||
for (BeanPersistListener listener : list) {
|
||||
if (listener.isRegisterFor(deployDesc.getBeanType())) {
|
||||
CoreLog.log.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName());
|
||||
CoreLog.log.log(DEBUG, "BeanPersistListener on[{0}] {1}", deployDesc.getFullName(), listener.getClass().getName());
|
||||
deployDesc.addPersistListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
@@ -28,7 +30,7 @@ final class PostConstructManager {
|
||||
void addPostConstructListeners(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanPostConstructListener c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
CoreLog.log.debug("BeanPostLoad on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
CoreLog.log.log(DEBUG, "BeanPostLoad on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||
deployDesc.addPostConstructListener(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
|
||||
/**
|
||||
* Default implementation for creating BeanControllers.
|
||||
*/
|
||||
@@ -28,7 +30,7 @@ final class PostLoadManager {
|
||||
void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
|
||||
for (BeanPostLoad c : list) {
|
||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||
CoreLog.log.debug("BeanPostLoad on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
||||
CoreLog.log.log(DEBUG, "BeanPostLoad on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||
deployDesc.addPostLoad(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class TableJoin {
|
||||
private final int queryHash;
|
||||
|
||||
private final PropertyForeignKey foreignKey;
|
||||
|
||||
|
||||
private final String extraWhere;
|
||||
|
||||
public TableJoin(DeployTableJoin deploy) {
|
||||
@@ -135,21 +135,21 @@ public final class TableJoin {
|
||||
|
||||
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);
|
||||
String a1 = ctx.tableAlias(names[0]);
|
||||
String a2 = ctx.tableAlias(prefix);
|
||||
addJoin(joinType, a1, a2, ctx);
|
||||
ctx.append(" and ").append(a2).append(predicate);
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx) {
|
||||
String[] names = SplitName.split(prefix);
|
||||
String a1 = ctx.getTableAlias(names[0]);
|
||||
String a2 = ctx.getTableAlias(prefix);
|
||||
String a1 = ctx.tableAlias(names[0]);
|
||||
String a2 = ctx.tableAlias(prefix);
|
||||
return addJoin(joinType, a1, a2, ctx);
|
||||
}
|
||||
|
||||
public SqlJoinType addJoin(SqlJoinType joinType, String a1, String a2, DbSqlContext ctx) {
|
||||
String joinLiteral = joinType.getLiteral(type);
|
||||
String joinLiteral = joinType.literal(type);
|
||||
ctx.addJoin(joinLiteral, table, columns(), a1, a2, extraWhere);
|
||||
return joinType.autoToOuter(type);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.deploy.generatedproperty;
|
||||
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebeaninternal.server.core.BasicTypeConverter;
|
||||
import io.ebean.core.type.BasicTypeConverter;
|
||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import io.ebeaninternal.server.deploy.DbReadContext;
|
||||
import io.ebeaninternal.server.deploy.DbSqlContext;
|
||||
import io.ebeaninternal.server.query.STreeProperty;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import io.ebeaninternal.server.deploy.DbReadContext;
|
||||
import io.ebeaninternal.server.deploy.DbSqlContext;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.core.DefaultSqlUpdate;
|
||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import io.ebeaninternal.server.deploy.DbReadContext;
|
||||
import io.ebeaninternal.server.deploy.DbSqlContext;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.ebeaninternal.server.deploy.DbReadContext;
|
||||
import io.ebeaninternal.server.deploy.DbSqlContext;
|
||||
import io.ebeaninternal.server.persist.MultiValueWrapper;
|
||||
import io.ebeaninternal.server.persist.platform.MultiValueBind;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -145,9 +145,7 @@ public final class IdBinderSimple implements IdBinder {
|
||||
@Override
|
||||
public void addIdInBindValues(SpiExpressionRequest request, Collection<?> values) {
|
||||
List<Object> copy = new ArrayList<>(values);
|
||||
for (int i = 0; i < copy.size(); i++) {
|
||||
copy.set(i, convertSetId(copy.get(i), null));
|
||||
}
|
||||
copy.replaceAll(idValue -> convertSetId(idValue, null));
|
||||
request.addBindValue(new MultiValueWrapper(copy));
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -152,7 +152,6 @@ public class DeployBeanDescriptor<T> {
|
||||
private DocStoreMode docStoreDelete;
|
||||
private DeployBeanProperty idProperty;
|
||||
private TableJoin primaryKeyJoin;
|
||||
private Object jacksonAnnotatedClass;
|
||||
|
||||
/**
|
||||
* Construct the BeanDescriptor.
|
||||
@@ -1130,14 +1129,4 @@ public class DeployBeanDescriptor<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the jackson annotated class, if jackson is present.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
Object /*AnnotatedClass*/ getJacksonAnnotatedClass() {
|
||||
if (jacksonAnnotatedClass == null) {
|
||||
jacksonAnnotatedClass = new DeployBeanObtainJackson(config, beanType).obtain();
|
||||
}
|
||||
return jacksonAnnotatedClass;
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package io.ebeaninternal.server.deploy.meta;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
|
||||
/**
|
||||
* Used to obtain the Jackson AnnotatedClass for a given bean type utlimately to obtain field level Jackson annotations.
|
||||
*/
|
||||
final class DeployBeanObtainJackson<T> {
|
||||
|
||||
private final DatabaseConfig config;
|
||||
private final Class<T> beanType;
|
||||
|
||||
DeployBeanObtainJackson(DatabaseConfig config, Class<T> beanType) {
|
||||
this.config = config;
|
||||
this.beanType = beanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Jackson AnnotatedClass for the given bean type.
|
||||
*/
|
||||
Object obtain() {
|
||||
ObjectMapper objectMapper = (ObjectMapper) config.getObjectMapper();
|
||||
JavaType javaType = objectMapper.getTypeFactory().constructType(beanType);
|
||||
return AnnotatedClassResolver.resolve(objectMapper.getDeserializationConfig(), javaType, objectMapper.getDeserializationConfig());
|
||||
}
|
||||
}
|
||||
Loaded 100 of 794 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user