mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
IntelliJ Inspect various improvements
This commit is contained in:
1 parent
2d733795c7
commit
81ef967d9f
44 files changed
+75
-109
No files matched your search
@@ -228,10 +228,9 @@ public final class BindParams implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Set a named In parameter that is multi-valued.
|
* 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);
|
Param p = getParam(name);
|
||||||
p.setInValue(new MultiValueWrapper(value));
|
p.setInValue(new MultiValueWrapper(value));
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public final class ScopeTrans {
|
|||||||
/**
|
/**
|
||||||
* Return the current/active transaction.
|
* Return the current/active transaction.
|
||||||
*/
|
*/
|
||||||
protected SpiTransaction getTransaction() {
|
SpiTransaction getTransaction() {
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ public final class ScopeTrans {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void commitTransaction() {
|
void commitTransaction() {
|
||||||
if (created) {
|
if (created) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
} else {
|
} else {
|
||||||
@@ -175,7 +175,7 @@ public final class ScopeTrans {
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rollback(Throwable e) {
|
void rollback(Throwable e) {
|
||||||
if (transaction != null && transaction.isActive()) {
|
if (transaction != null && transaction.isActive()) {
|
||||||
// transaction is null for NOT_SUPPORTED and sometimes SUPPORTS
|
// transaction is null for NOT_SUPPORTED and sometimes SUPPORTS
|
||||||
// and Inactive (already rolled back) if nested REQUIRED
|
// and Inactive (already rolled back) if nested REQUIRED
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import javax.persistence.PersistenceException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage scoped (typically thread local) transactions.
|
* Manage scoped (typically thread local) transactions.
|
||||||
*
|
* <p>
|
||||||
* These can be nested and internally they are pushed and popped from a stack.
|
* These can be nested and internally they are pushed and popped from a stack.
|
||||||
*/
|
*/
|
||||||
public final class ScopedTransaction extends SpiTransactionProxy {
|
public final class ScopedTransaction extends SpiTransactionProxy {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public interface SpiExpression extends Expression {
|
public interface SpiExpression extends Expression {
|
||||||
|
|
||||||
static final String SQL_TRUE = "1=1";
|
String SQL_TRUE = "1=1";
|
||||||
static final String SQL_FALSE = "1=0";
|
String SQL_FALSE = "1=0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplify nested expressions if possible.
|
* Simplify nested expressions if possible.
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public final class TransactionEvent implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the CacheChangeSet that we add cache notification messages to.
|
* 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
|
* We want to add to this change set as we process requests allowing the
|
||||||
* PersistRequestBean to be garbage collected for large transactions.
|
* PersistRequestBean to be garbage collected for large transactions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.ebeaninternal.api;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Event codes used in transaction profiling.
|
* Event codes used in transaction profiling.
|
||||||
*
|
* <p>
|
||||||
* These appear in verbose transaction profile logs.
|
* These appear in verbose transaction profile logs.
|
||||||
*/
|
*/
|
||||||
public interface TxnProfileEventCodes {
|
public interface TxnProfileEventCodes {
|
||||||
|
|||||||
@@ -100,11 +100,7 @@ final class DumpMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logCount(MetaCountMetric metric) {
|
private void logCount(MetaCountMetric metric) {
|
||||||
|
out(padNameTimed(metric.name()) + " count:" + pad(metric.count()));
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(padNameTimed(metric.name())).append(" ");
|
|
||||||
sb.append(" count:").append(pad(metric.count()));
|
|
||||||
out(sb.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void out(String sb) {
|
private void out(String sb) {
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
|||||||
/**
|
/**
|
||||||
* Add this statement to JDBC batch for later execution.
|
* Add this statement to JDBC batch for later execution.
|
||||||
*/
|
*/
|
||||||
public int addBatch() {
|
public void addBatch() {
|
||||||
this.addBatch = true;
|
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
|
* Maybe hit the bean cache returning true if everything was obtained from the
|
||||||
* cache (that there were no misses).
|
* cache (that there were no misses).
|
||||||
*
|
* <p>
|
||||||
* Do this for findList() on many natural keys or many Ids.
|
* Do this for findList() on many natural keys or many Ids.
|
||||||
*/
|
*/
|
||||||
boolean getFromBeanCache();
|
boolean getFromBeanCache();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.sql.ResultSet;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hold the JDBC PreparedStatement and ResultSet.
|
* Hold the JDBC PreparedStatement and ResultSet.
|
||||||
*
|
* <p>
|
||||||
* These both must be closed properly when done.
|
* These both must be closed properly when done.
|
||||||
*/
|
*/
|
||||||
public final class SpiResultSet {
|
public final class SpiResultSet {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class ManifestReader {
|
|||||||
/**
|
/**
|
||||||
* Read all the specific manifest files and return the set of packages containing type query beans.
|
* 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 {
|
try {
|
||||||
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
||||||
while (resources.hasMoreElements()) {
|
while (resources.hasMoreElements()) {
|
||||||
@@ -66,7 +66,6 @@ class ManifestReader {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log(WARNING, "Error reading " + resourcePath + " manifest resources", e);
|
log.log(WARNING, "Error reading " + resourcePath + " manifest resources", e);
|
||||||
}
|
}
|
||||||
return packageSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3157,18 +3157,17 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
/**
|
/**
|
||||||
* Return true if any mutable properties are dirty.
|
* Return true if any mutable properties are dirty.
|
||||||
*/
|
*/
|
||||||
public boolean checkAnyMutableProperties(EntityBeanIntercept ebi) {
|
public void checkAnyMutableProperties(EntityBeanIntercept ebi) {
|
||||||
for (BeanProperty beanProperty : propertiesMutable) {
|
for (BeanProperty beanProperty : propertiesMutable) {
|
||||||
int propertyIndex = beanProperty.propertyIndex();
|
int propertyIndex = beanProperty.propertyIndex();
|
||||||
if (ebi.isLoadedProperty(propertyIndex)) {
|
if (ebi.isLoadedProperty(propertyIndex)) {
|
||||||
Object value = beanProperty.getValue(ebi.getOwner());
|
Object value = beanProperty.getValue(ebi.getOwner());
|
||||||
if (beanProperty.checkMutable(value, ebi.isDirtyProperty(propertyIndex), ebi)) {
|
if (beanProperty.checkMutable(value, ebi.isDirtyProperty(propertyIndex), ebi)) {
|
||||||
ebi.markPropertyAsChanged(propertyIndex);
|
ebi.markPropertyAsChanged(propertyIndex);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrencyMode concurrencyMode(EntityBeanIntercept ebi) {
|
public ConcurrencyMode concurrencyMode(EntityBeanIntercept ebi) {
|
||||||
|
|||||||
+1
-3
@@ -706,9 +706,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<EntityBeanIntercept> loaded = new HashSet<>();
|
Set<EntityBeanIntercept> loaded = new HashSet<>();
|
||||||
Iterator<Map.Entry<Object, Object>> iterator = hits.entrySet().iterator();
|
for (Map.Entry<Object, Object> hit : hits.entrySet()) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Map.Entry<Object, Object> hit = iterator.next();
|
|
||||||
Object key = hit.getKey();
|
Object key = hit.getKey();
|
||||||
EntityBeanIntercept ebi = ebis.remove(key);
|
EntityBeanIntercept ebi = ebis.remove(key);
|
||||||
CachedBeanData cacheData = (CachedBeanData) hit.getValue();
|
CachedBeanData cacheData = (CachedBeanData) hit.getValue();
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
|||||||
*/
|
*/
|
||||||
public boolean isUpdateable() {
|
public boolean isUpdateable() {
|
||||||
TableJoinColumn[] columns = tableJoin.columns();
|
TableJoinColumn[] columns = tableJoin.columns();
|
||||||
if (columns.length <= 0) {
|
if (columns.length == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (TableJoinColumn column : columns) {
|
for (TableJoinColumn column : columns) {
|
||||||
@@ -383,7 +383,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
|||||||
*/
|
*/
|
||||||
public boolean isInsertable() {
|
public boolean isInsertable() {
|
||||||
TableJoinColumn[] columns = tableJoin.columns();
|
TableJoinColumn[] columns = tableJoin.columns();
|
||||||
if (columns.length <= 0) {
|
if (columns.length == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (TableJoinColumn column : columns) {
|
for (TableJoinColumn column : columns) {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean property for synthetic sort order value / order column.
|
* Bean property for synthetic sort order value / order column.
|
||||||
*
|
* <p>
|
||||||
* The value of which is held on the entity bean intercept.
|
* The value of which is held on the entity bean intercept.
|
||||||
*/
|
*/
|
||||||
public final class BeanPropertyOrderColumn extends BeanProperty {
|
public final class BeanPropertyOrderColumn extends BeanProperty {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public final class DbMigrationInfo {
|
|||||||
if (scripts.length == 0) {
|
if (scripts.length == 0) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} else {
|
} else {
|
||||||
return Collections.unmodifiableList(Arrays.asList(scripts));
|
return List.of(scripts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,9 +145,7 @@ public final class IdBinderSimple implements IdBinder {
|
|||||||
@Override
|
@Override
|
||||||
public void addIdInBindValues(SpiExpressionRequest request, Collection<?> values) {
|
public void addIdInBindValues(SpiExpressionRequest request, Collection<?> values) {
|
||||||
List<Object> copy = new ArrayList<>(values);
|
List<Object> copy = new ArrayList<>(values);
|
||||||
for (int i = 0; i < copy.size(); i++) {
|
copy.replaceAll(idValue -> convertSetId(idValue, null));
|
||||||
copy.set(i, convertSetId(copy.get(i), null));
|
|
||||||
}
|
|
||||||
request.addBindValue(new MultiValueWrapper(copy));
|
request.addBindValue(new MultiValueWrapper(copy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -12,10 +12,10 @@ public final class DeployIdentityMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IdType type;
|
private IdType type;
|
||||||
private IdentityGenerated generated;
|
private final IdentityGenerated generated;
|
||||||
private int start;
|
private int start;
|
||||||
private int increment;
|
private int increment;
|
||||||
private int cache;
|
private final int cache;
|
||||||
private String sequenceName;
|
private String sequenceName;
|
||||||
private boolean platformDefault;
|
private boolean platformDefault;
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ public final class DeployTableJoin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the clause of an extra @Where annotation.
|
* Returns the clause of an extra @Where annotation.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public String getExtraWhere() {
|
public String getExtraWhere() {
|
||||||
return extraWhere;
|
return extraWhere;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds property and constructor meta data for a given DTO bean type.
|
* Holds property and constructor meta-data for a given DTO bean type.
|
||||||
*
|
* <p>
|
||||||
* Uses this to map a mapping request (columns) to a 'query plan' (constructor and setters).
|
* Uses this to map a mapping request (columns) to a 'query plan' (constructor and setters).
|
||||||
*/
|
*/
|
||||||
final class DtoMeta {
|
final class DtoMeta {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public final class CharMatch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ta[] = other.toCharArray();
|
char[] ta = other.toCharArray();
|
||||||
|
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
while (++pos < maxLength) {
|
while (++pos < maxLength) {
|
||||||
@@ -42,7 +42,7 @@ public final class CharMatch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ta[] = other.toCharArray();
|
char[] ta = other.toCharArray();
|
||||||
|
|
||||||
int offset = ta.length - maxLength;
|
int offset = ta.length - maxLength;
|
||||||
int pos = maxLength;
|
int pos = maxLength;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public final class ElFilter<T> implements Filter<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isMatch(T bean) {
|
boolean isMatch(T bean) {
|
||||||
for (ElMatcher<T> matcher : matches) {
|
for (ElMatcher<T> matcher : matches) {
|
||||||
if (!matcher.isMatch(bean)) {
|
if (!matcher.isMatch(bean)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -342,7 +342,6 @@ abstract class EqlWhereListener<T> extends EQLBaseListener {
|
|||||||
case ':':
|
case ':':
|
||||||
return EqlValueType.NAMED_PARAM;
|
return EqlValueType.NAMED_PARAM;
|
||||||
case 't':
|
case 't':
|
||||||
return EqlValueType.BOOL;
|
|
||||||
case 'f':
|
case 'f':
|
||||||
return EqlValueType.BOOL;
|
return EqlValueType.BOOL;
|
||||||
case '\'':
|
case '\'':
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
stateFile, propNodeId, getNodeIdentifier());
|
stateFile, propNodeId, getNodeIdentifier());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Integer seq = Integer.valueOf(prop.getProperty("clockSeq")) & 0x3FFF;
|
Integer seq = Integer.parseInt(prop.getProperty("clockSeq")) & 0x3FFF;
|
||||||
Long ts = Long.valueOf(prop.getProperty("timeStamp"));
|
Long ts = Long.valueOf(prop.getProperty("timeStamp"));
|
||||||
clockSeq.set(seq);
|
clockSeq.set(seq);
|
||||||
timeStamp.set(ts);
|
timeStamp.set(ts);
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ import static java.lang.System.Logger.Level.INFO;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* IdGenerator for (pseudo) type 1 UUIDs.
|
* IdGenerator for (pseudo) type 1 UUIDs.
|
||||||
*
|
* <p>
|
||||||
* This implementation generates a type 1 UUID according to
|
* This implementation generates a type 1 UUID according to
|
||||||
* https://tools.ietf.org/html/rfc4122.html#section-4.2
|
* https://tools.ietf.org/html/rfc4122.html#section-4.2
|
||||||
* but has no persistence storage. It generates a new random 47 bit node ID with every
|
* but has no persistence storage. It generates a new random 47 bit node ID with every
|
||||||
* UUID.
|
* UUID.
|
||||||
*
|
* <p>
|
||||||
* Use this, if you want randomness in your UUIDs but want to take advantage of index
|
* Use this, if you want randomness in your UUIDs but want to take advantage of index
|
||||||
* optimizations of the database. It may be good with AUTO_BINARY_OPTIMIZED and MySql.
|
* optimizations of the database. It may be good with AUTO_BINARY_OPTIMIZED and MySql.
|
||||||
*
|
* <p>
|
||||||
* See: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
|
* See: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
|
||||||
*/
|
*/
|
||||||
public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
||||||
@@ -41,16 +41,16 @@ public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
|||||||
|
|
||||||
private final SecureRandom numberGenerator = new SecureRandom();
|
private final SecureRandom numberGenerator = new SecureRandom();
|
||||||
|
|
||||||
protected AtomicLong timeStamp = new AtomicLong(currentUuidTime());
|
protected final AtomicLong timeStamp = new AtomicLong(currentUuidTime());
|
||||||
|
|
||||||
private AtomicLong nanoToMilliOffset = new AtomicLong(currentUuidTime());
|
private final AtomicLong nanoToMilliOffset = new AtomicLong(currentUuidTime());
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the uuid epoch.
|
* Returns the uuid epoch.
|
||||||
*
|
* <p>
|
||||||
* This is the number of 100ns intervals since 1582-10-15 00:00:00
|
* This is the number of 100ns intervals since 1582-10-15 00:00:00
|
||||||
*/
|
*/
|
||||||
private static long currentUuidTime() {
|
private static long currentUuidTime() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* IdGenerator for java util UUID.
|
* IdGenerator for java util UUID.
|
||||||
*
|
* <p>
|
||||||
* This generator generates a 60bit random UUID according to
|
* This generator generates a 60bit random UUID according to
|
||||||
* https://tools.ietf.org/html/rfc4122.html#section-4.4
|
* https://tools.ietf.org/html/rfc4122.html#section-4.4
|
||||||
* Use this generator if you want truly random UUIDs
|
* Use this generator if you want truly random UUIDs
|
||||||
|
|||||||
@@ -163,11 +163,10 @@ public final class Binder {
|
|||||||
/**
|
/**
|
||||||
* Bind an Object with unknown data type.
|
* Bind an Object with unknown data type.
|
||||||
*/
|
*/
|
||||||
public Object bindObject(DataBind dataBind, Object value) throws SQLException {
|
public void bindObject(DataBind dataBind, Object value) throws SQLException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// null of unknown type
|
// null of unknown type
|
||||||
bindObject(dataBind, null, Types.OTHER);
|
bindObject(dataBind, null, Types.OTHER);
|
||||||
return null;
|
|
||||||
|
|
||||||
} else if (value instanceof MultiValueWrapper) {
|
} else if (value instanceof MultiValueWrapper) {
|
||||||
MultiValueWrapper wrapper = (MultiValueWrapper) value;
|
MultiValueWrapper wrapper = (MultiValueWrapper) value;
|
||||||
@@ -177,7 +176,6 @@ public final class Binder {
|
|||||||
int dbType = type.jdbcType();
|
int dbType = type.jdbcType();
|
||||||
// let the multiValueBind decide what to do with the value
|
// let the multiValueBind decide what to do with the value
|
||||||
multiValueBind.bindMultiValues(dataBind, values, type, one -> bindObject(dataBind, one, dbType));
|
multiValueBind.bindMultiValues(dataBind, values, type, one -> bindObject(dataBind, one, dbType));
|
||||||
return values;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ScalarType<?> type = getScalarType(value.getClass());
|
ScalarType<?> type = getScalarType(value.getClass());
|
||||||
@@ -186,7 +184,6 @@ public final class Binder {
|
|||||||
value = type.toJdbcType(value);
|
value = type.toJdbcType(value);
|
||||||
}
|
}
|
||||||
bindObject(dataBind, value, type.jdbcType());
|
bindObject(dataBind, value, type.jdbcType());
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -60,9 +60,7 @@ public class MultiValueBind {
|
|||||||
sb.append(" not");
|
sb.append(" not");
|
||||||
}
|
}
|
||||||
sb.append(" in (?");
|
sb.append(" in (?");
|
||||||
for (int i = 1; i < size; i++) {
|
sb.append(",?".repeat(Math.max(0, size - 1)));
|
||||||
sb.append(",?");
|
|
||||||
}
|
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNullElse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the SQL SELECT statements taking into account the physical
|
* Generates the SQL SELECT statements taking into account the physical
|
||||||
* deployment properties.
|
* deployment properties.
|
||||||
@@ -411,11 +413,7 @@ final class CQueryBuilder {
|
|||||||
String tableName = lower(metaData.getTableName(i));
|
String tableName = lower(metaData.getTableName(i));
|
||||||
String columnName = lower(metaData.getColumnName(i));
|
String columnName = lower(metaData.getColumnName(i));
|
||||||
String path = desc.findBeanPath(schemaName, tableName, columnName);
|
String path = desc.findBeanPath(schemaName, tableName, columnName);
|
||||||
if (path != null) {
|
propertyNames.add(requireNonNullElse(path, SpiRawSql.IGNORE_COLUMN));
|
||||||
propertyNames.add(path);
|
|
||||||
} else {
|
|
||||||
propertyNames.add(SpiRawSql.IGNORE_COLUMN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
RawSql rawSql = RawSqlBuilder.resultSet(resultSet, propertyNames.toArray(new String[0]));
|
RawSql rawSql = RawSqlBuilder.resultSet(resultSet, propertyNames.toArray(new String[0]));
|
||||||
query.setRawSql(rawSql);
|
query.setRawSql(rawSql);
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ public final class CQueryPredicates {
|
|||||||
// orderById is already in the order by clause
|
// orderById is already in the order by clause
|
||||||
return orderBy;
|
return orderBy;
|
||||||
}
|
}
|
||||||
if (idPos <= -1 || idPos >= manyPos) {
|
if (idPos == -1 || idPos >= manyPos) {
|
||||||
if (idPos > manyPos) {
|
if (idPos > manyPos) {
|
||||||
// there was an error with the order by...
|
// there was an error with the order by...
|
||||||
String msg = "A Query on [" + desc + "] includes a join to a 'many' association [" + manyProp.name()
|
String msg = "A Query on [" + desc + "] includes a join to a 'many' association [" + manyProp.name()
|
||||||
|
|||||||
@@ -83,5 +83,5 @@ interface SqlTreeNode {
|
|||||||
* Unselect lobs (for distinct queries on DB2 and Oracle).
|
* Unselect lobs (for distinct queries on DB2 and Oracle).
|
||||||
*/
|
*/
|
||||||
default void unselectLobs() {
|
default void unselectLobs() {
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
|||||||
return expressionFactory;
|
return expressionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void createExtraJoinsToSupportManyWhereClause() {
|
private void createExtraJoinsToSupportManyWhereClause() {
|
||||||
manyWhereJoins = new ManyWhereJoins();
|
manyWhereJoins = new ManyWhereJoins();
|
||||||
if (whereExpressions != null) {
|
if (whereExpressions != null) {
|
||||||
whereExpressions.containsMany(beanDescriptor, manyWhereJoins);
|
whereExpressions.containsMany(beanDescriptor, manyWhereJoins);
|
||||||
@@ -1499,12 +1499,12 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final <A> List<A> findSingleAttributeList() {
|
public final <A> List<A> findSingleAttributeList() {
|
||||||
return (List<A>) server.findSingleAttributeList(this, transaction);
|
return server.findSingleAttributeList(this, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final <A> Set<A> findSingleAttributeSet() {
|
public final <A> Set<A> findSingleAttributeSet() {
|
||||||
return (Set<A>) server.findSingleAttributeSet(this, transaction);
|
return server.findSingleAttributeSet(this, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ public final class OrmQueryDetail implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Add or replace the fetch detail.
|
* Add or replace the fetch detail.
|
||||||
*/
|
*/
|
||||||
protected void fetch(OrmQueryProperties chunk) {
|
void fetch(OrmQueryProperties chunk) {
|
||||||
String path = chunk.getPath();
|
String path = chunk.getPath();
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
baseProps = chunk;
|
baseProps = chunk;
|
||||||
|
|||||||
@@ -144,12 +144,9 @@ public final class SimpleTextParser {
|
|||||||
private boolean isOperator(char c) {
|
private boolean isOperator(char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '<':
|
case '<':
|
||||||
return true;
|
|
||||||
case '>':
|
|
||||||
return true;
|
|
||||||
case '=':
|
|
||||||
return true;
|
|
||||||
case '!':
|
case '!':
|
||||||
|
case '=':
|
||||||
|
case '>':
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct for unparsed SQL.
|
* Construct for unparsed SQL.
|
||||||
*/
|
*/
|
||||||
protected Sql(String unparsedSql) {
|
Sql(String unparsedSql) {
|
||||||
this.parsed = false;
|
this.parsed = false;
|
||||||
this.unparsedSql = unparsedSql;
|
this.unparsedSql = unparsedSql;
|
||||||
this.preFrom = null;
|
this.preFrom = null;
|
||||||
@@ -80,7 +80,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct for parsed SQL.
|
* Construct for parsed SQL.
|
||||||
*/
|
*/
|
||||||
protected Sql(String unparsedSql, String preFrom, String preWhere, boolean andWhereExpr,
|
Sql(String unparsedSql, String preFrom, String preWhere, boolean andWhereExpr,
|
||||||
String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) {
|
String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) {
|
||||||
|
|
||||||
this.unparsedSql = unparsedSql;
|
this.unparsedSql = unparsedSql;
|
||||||
@@ -199,7 +199,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct from parsed sql where the columns have been identified.
|
* Construct from parsed sql where the columns have been identified.
|
||||||
*/
|
*/
|
||||||
protected ColumnMapping(List<Column> columns) {
|
ColumnMapping(List<Column> columns) {
|
||||||
this.immutable = false;
|
this.immutable = false;
|
||||||
this.parsed = true;
|
this.parsed = true;
|
||||||
this.propertyMap = null;
|
this.propertyMap = null;
|
||||||
@@ -213,7 +213,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct for unparsed sql.
|
* Construct for unparsed sql.
|
||||||
*/
|
*/
|
||||||
protected ColumnMapping() {
|
ColumnMapping() {
|
||||||
this.immutable = false;
|
this.immutable = false;
|
||||||
this.parsed = false;
|
this.parsed = false;
|
||||||
this.propertyMap = null;
|
this.propertyMap = null;
|
||||||
@@ -224,7 +224,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct for ResultSet use.
|
* Construct for ResultSet use.
|
||||||
*/
|
*/
|
||||||
protected ColumnMapping(String... propertyNames) {
|
ColumnMapping(String... propertyNames) {
|
||||||
this.immutable = false;
|
this.immutable = false;
|
||||||
this.parsed = false;
|
this.parsed = false;
|
||||||
this.propertyMap = null;
|
this.propertyMap = null;
|
||||||
@@ -240,7 +240,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Construct an immutable ColumnMapping based on collected information.
|
* Construct an immutable ColumnMapping based on collected information.
|
||||||
*/
|
*/
|
||||||
protected ColumnMapping(boolean parsed, LinkedHashMap<String, Column> dbColumnMap) {
|
ColumnMapping(boolean parsed, LinkedHashMap<String, Column> dbColumnMap) {
|
||||||
this.immutable = true;
|
this.immutable = true;
|
||||||
this.parsed = parsed;
|
this.parsed = parsed;
|
||||||
this.dbColumnMap = dbColumnMap;
|
this.dbColumnMap = dbColumnMap;
|
||||||
@@ -281,17 +281,14 @@ public interface SpiRawSql extends RawSql {
|
|||||||
*
|
*
|
||||||
* @throws IllegalStateException when a propertyName has not been defined for a column.
|
* @throws IllegalStateException when a propertyName has not been defined for a column.
|
||||||
*/
|
*/
|
||||||
protected ColumnMapping createImmutableCopy() {
|
ColumnMapping createImmutableCopy() {
|
||||||
|
|
||||||
for (Column c : dbColumnMap.values()) {
|
for (Column c : dbColumnMap.values()) {
|
||||||
c.checkMapping();
|
c.checkMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ColumnMapping(parsed, dbColumnMap);
|
return new ColumnMapping(parsed, dbColumnMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void columnMapping(String dbColumn, String propertyName) {
|
void columnMapping(String dbColumn, String propertyName) {
|
||||||
|
|
||||||
if (immutable) {
|
if (immutable) {
|
||||||
throw new IllegalStateException("Should never happen");
|
throw new IllegalStateException("Should never happen");
|
||||||
}
|
}
|
||||||
@@ -330,7 +327,7 @@ public interface SpiRawSql extends RawSql {
|
|||||||
/**
|
/**
|
||||||
* Return the column mapping.
|
* Return the column mapping.
|
||||||
*/
|
*/
|
||||||
protected Map<String, Column> mapping() {
|
Map<String, Column> mapping() {
|
||||||
return dbColumnMap;
|
return dbColumnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,8 +25,8 @@ public class DefaultReadAuditLogger implements ReadAuditLogger {
|
|||||||
private static final System.Logger auditLogger = AppLog.getLogger("io.ebean.ReadAudit");
|
private static final System.Logger auditLogger = AppLog.getLogger("io.ebean.ReadAudit");
|
||||||
|
|
||||||
protected final JsonFactory jsonFactory = new JsonFactory();
|
protected final JsonFactory jsonFactory = new JsonFactory();
|
||||||
protected int defaultQueryBuffer = 500;
|
protected final int defaultQueryBuffer = 500;
|
||||||
protected int defaultReadBuffer = 150;
|
protected final int defaultReadBuffer = 150;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the query plan details in JSON format to the logger.
|
* Write the query plan details in JSON format to the logger.
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
@Override
|
@Override
|
||||||
public final void depthDecrement() {
|
public final void depthDecrement() {
|
||||||
if (depth != 0) {
|
if (depth != 0) {
|
||||||
depth += -1;
|
depth -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
|||||||
if (!dataInput.readBoolean()) {
|
if (!dataInput.readBoolean()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new BigDecimal(dataInput.readDouble());
|
return BigDecimal.valueOf(dataInput.readDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.type;
|
|||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import io.ebean.core.type.*;
|
import io.ebean.core.type.*;
|
||||||
import io.ebean.core.type.BasicTypeConverter;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
|
|||||||
@@ -146,12 +146,10 @@ final class ScalarTypeFile extends ScalarTypeBase<File> {
|
|||||||
/**
|
/**
|
||||||
* Helper method to pump bytes from input to output.
|
* Helper method to pump bytes from input to output.
|
||||||
*/
|
*/
|
||||||
public long pump(InputStream is, OutputStream out) throws IOException {
|
public void pump(InputStream is, OutputStream out) throws IOException {
|
||||||
|
|
||||||
long totalBytes = 0;
|
long totalBytes = 0;
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
OutputStream output = null;
|
OutputStream output = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
input = new BufferedInputStream(is, bufferSize);
|
input = new BufferedInputStream(is, bufferSize);
|
||||||
output = new BufferedOutputStream(out, bufferSize);
|
output = new BufferedOutputStream(out, bufferSize);
|
||||||
@@ -162,11 +160,7 @@ final class ScalarTypeFile extends ScalarTypeBase<File> {
|
|||||||
output.write(buffer, 0, length);
|
output.write(buffer, 0, length);
|
||||||
totalBytes += length;
|
totalBytes += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.flush();
|
output.flush();
|
||||||
|
|
||||||
return totalBytes;
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* This class is a modified version of TypeResolver from https://github.com/jhalterman/typetools
|
* This class is a modified version of TypeResolver from https://github.com/jhalterman/typetools
|
||||||
* which is Apache 2 license.
|
* which is Apache 2 license.
|
||||||
*
|
* <p>
|
||||||
* It is a cut down version removing the lambda support and related sun.misc.Unsafe use etc.
|
* It is a cut down version removing the lambda support and related sun.misc.Unsafe use etc.
|
||||||
*/
|
*/
|
||||||
final class TypeResolver {
|
final class TypeResolver {
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ public final class BindParamsParser {
|
|||||||
|
|
||||||
private void addCollectionParams(OrderedList orderedList, Param param, Collection<?> inValue) {
|
private void addCollectionParams(OrderedList orderedList, Param param, Collection<?> inValue) {
|
||||||
// Chop up Collection parameter into a number of individual parameters
|
// Chop up Collection parameter into a number of individual parameters
|
||||||
Collection<?> collection = inValue;
|
for (int c = 0; c < inValue.size(); c++) {
|
||||||
for (int c = 0; c < collection.size(); c++) {
|
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
orderedList.appendSql(",");
|
orderedList.appendSql(",");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.json.PathStack;
|
|||||||
*/
|
*/
|
||||||
public abstract class DocPropertyAdapter implements DocPropertyVisitor {
|
public abstract class DocPropertyAdapter implements DocPropertyVisitor {
|
||||||
|
|
||||||
protected PathStack pathStack = new PathStack();
|
protected final PathStack pathStack = new PathStack();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitProperty(DocPropertyMapping property) {
|
public void visitProperty(DocPropertyMapping property) {
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import io.ebean.docstore.DocMapping;
|
|||||||
*/
|
*/
|
||||||
public final class DocumentMapping implements DocMapping {
|
public final class DocumentMapping implements DocMapping {
|
||||||
|
|
||||||
protected final String queueId;
|
private final String queueId;
|
||||||
protected final String name;
|
private final String name;
|
||||||
protected final String type;
|
private final String type;
|
||||||
protected final FetchPath paths;
|
private final FetchPath paths;
|
||||||
protected final DocPropertyMapping properties;
|
private final DocPropertyMapping properties;
|
||||||
protected int shards;
|
private int shards;
|
||||||
protected int replicas;
|
private int replicas;
|
||||||
|
|
||||||
public DocumentMapping(String queueId, String name, String type, FetchPath paths, DocPropertyMapping properties, int shards, int replicas) {
|
public DocumentMapping(String queueId, String name, String type, FetchPath paths, DocPropertyMapping properties, int shards, int replicas) {
|
||||||
this.queueId = queueId;
|
this.queueId = queueId;
|
||||||
|
|||||||
Reference in new issue
Block a user