mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2318 - Refactor internals - final classes in expression packages
This commit is contained in:
1 parent
f33e54d8ba
commit
0413d89a9e
53 files changed
+80
-166
No files matched your search
@@ -14,7 +14,7 @@ import io.ebeaninternal.api.NaturalKeyQueryData;
|
|||||||
/**
|
/**
|
||||||
* Base class for simple expressions.
|
* Base class for simple expressions.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractExpression implements SpiExpression {
|
abstract class AbstractExpression implements SpiExpression {
|
||||||
|
|
||||||
protected String propName;
|
protected String propName;
|
||||||
|
|
||||||
@@ -66,7 +66,6 @@ public abstract class AbstractExpression implements SpiExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||||
|
|
||||||
propertyContainsMany(propName, desc, manyWhereJoin);
|
propertyContainsMany(propName, desc, manyWhereJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +102,6 @@ public abstract class AbstractExpression implements SpiExpression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final ElPropertyValue getElProp(SpiExpressionRequest request) {
|
protected final ElPropertyValue getElProp(SpiExpressionRequest request) {
|
||||||
|
|
||||||
return request.getBeanDescriptor().getElGetValue(propName);
|
return request.getBeanDescriptor().getElGetValue(propName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -10,7 +10,7 @@ import io.ebeaninternal.api.SpiExpressionRequest;
|
|||||||
* This means they can not be part of a SQL query nor do they use the built in query plan cache etc.
|
* This means they can not be part of a SQL query nor do they use the built in query plan cache etc.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTextExpression extends AbstractExpression {
|
abstract class AbstractTextExpression extends AbstractExpression {
|
||||||
|
|
||||||
AbstractTextExpression(String propName) {
|
AbstractTextExpression(String propName) {
|
||||||
super(propName);
|
super(propName);
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.expression;
|
|||||||
/**
|
/**
|
||||||
* Abstract expression that helps with named parameter use.
|
* Abstract expression that helps with named parameter use.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractValueExpression extends AbstractExpression {
|
abstract class AbstractValueExpression extends AbstractExpression {
|
||||||
|
|
||||||
protected final Object bindValue;
|
protected final Object bindValue;
|
||||||
|
|
||||||
|
|||||||
+2
-15
@@ -13,7 +13,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
class AllEqualsExpression extends NonPrepareExpression {
|
final class AllEqualsExpression extends NonPrepareExpression {
|
||||||
|
|
||||||
private final Map<String, Object> propMap;
|
private final Map<String, Object> propMap;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
this.propMap = propMap;
|
this.propMap = propMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String name(String propName) {
|
String name(String propName) {
|
||||||
return propName;
|
return propName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,6 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBindValues(SpiExpressionRequest request) {
|
public void addBindValues(SpiExpressionRequest request) {
|
||||||
|
|
||||||
if (propMap.isEmpty()) {
|
if (propMap.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,23 +69,17 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSql(SpiExpressionRequest request) {
|
public void addSql(SpiExpressionRequest request) {
|
||||||
|
|
||||||
if (propMap.isEmpty()) {
|
if (propMap.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.append("(");
|
request.append("(");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Map.Entry<String, Object> entry : propMap.entrySet()) {
|
for (Map.Entry<String, Object> entry : propMap.entrySet()) {
|
||||||
|
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
String propName = entry.getKey();
|
String propName = entry.getKey();
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
request.append("and ");
|
request.append("and ");
|
||||||
}
|
}
|
||||||
|
|
||||||
request.append(name(propName));
|
request.append(name(propName));
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
request.append(" is null ");
|
request.append(" is null ");
|
||||||
@@ -106,7 +99,6 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void queryPlanHash(StringBuilder builder) {
|
public void queryPlanHash(StringBuilder builder) {
|
||||||
|
|
||||||
builder.append("AllEquals[");
|
builder.append("AllEquals[");
|
||||||
for (Entry<String, Object> entry : propMap.entrySet()) {
|
for (Entry<String, Object> entry : propMap.entrySet()) {
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
@@ -135,20 +127,16 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
if (!(other instanceof AllEqualsExpression)) {
|
if (!(other instanceof AllEqualsExpression)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AllEqualsExpression that = (AllEqualsExpression) other;
|
AllEqualsExpression that = (AllEqualsExpression) other;
|
||||||
return isSameByValue(that, true);
|
return isSameByValue(that, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSameByValue(AllEqualsExpression that, boolean byValue) {
|
private boolean isSameByValue(AllEqualsExpression that, boolean byValue) {
|
||||||
|
|
||||||
if (propMap.size() != that.propMap.size()) {
|
if (propMap.size() != that.propMap.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Entry<String, Object>> thisIt = propMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> thisIt = propMap.entrySet().iterator();
|
||||||
Iterator<Entry<String, Object>> thatIt = that.propMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> thatIt = that.propMap.entrySet().iterator();
|
||||||
|
|
||||||
while (thisIt.hasNext() && thatIt.hasNext()) {
|
while (thisIt.hasNext() && thatIt.hasNext()) {
|
||||||
Entry<String, Object> thisNext = thisIt.next();
|
Entry<String, Object> thisNext = thisIt.next();
|
||||||
Entry<String, Object> thatNext = thatIt.next();
|
Entry<String, Object> thatNext = thatIt.next();
|
||||||
@@ -160,7 +148,6 @@ class AllEqualsExpression extends NonPrepareExpression {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-3
@@ -9,10 +9,9 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Contains expression for ARRAY type.
|
* Contains expression for ARRAY type.
|
||||||
*/
|
*/
|
||||||
public class ArrayContainsExpression extends AbstractExpression {
|
final class ArrayContainsExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean contains;
|
private final boolean contains;
|
||||||
|
|
||||||
private final Object[] values;
|
private final Object[] values;
|
||||||
|
|
||||||
ArrayContainsExpression(String propName, boolean contains, Object... values) {
|
ArrayContainsExpression(String propName, boolean contains, Object... values) {
|
||||||
@@ -26,7 +25,6 @@ public class ArrayContainsExpression extends AbstractExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||||
|
|
||||||
if (values.length == 1) {
|
if (values.length == 1) {
|
||||||
context.writeEqualTo(propName, values[0]);
|
context.writeEqualTo(propName, values[0]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* IsEmpty expression for ARRAY type.
|
* IsEmpty expression for ARRAY type.
|
||||||
*/
|
*/
|
||||||
public class ArrayIsEmptyExpression extends AbstractExpression {
|
final class ArrayIsEmptyExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean empty;
|
private final boolean empty;
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ import io.ebeaninternal.api.SpiExpressionRequest;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class BetweenExpression extends AbstractExpression {
|
final class BetweenExpression extends AbstractExpression {
|
||||||
|
|
||||||
private static final String _BETWEEN = " between ? and ?";
|
private static final String _BETWEEN = " between ? and ?";
|
||||||
|
|
||||||
private final Object valueHigh;
|
private final Object valueHigh;
|
||||||
|
|
||||||
private final Object valueLow;
|
private final Object valueLow;
|
||||||
|
|
||||||
BetweenExpression(String propertyName, Object valueLow, Object valueHigh) {
|
BetweenExpression(String propertyName, Object valueLow, Object valueHigh) {
|
||||||
|
|||||||
+2
-4
@@ -14,7 +14,7 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Between expression where a value is between two properties.
|
* Between expression where a value is between two properties.
|
||||||
*/
|
*/
|
||||||
class BetweenPropertyExpression extends NonPrepareExpression {
|
final class BetweenPropertyExpression extends NonPrepareExpression {
|
||||||
|
|
||||||
private static final String BETWEEN = " between ";
|
private static final String BETWEEN = " between ";
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
|||||||
this.highProperty = path + "." + highProperty;
|
this.highProperty = path + "." + highProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String name(String propName) {
|
String name(String propName) {
|
||||||
return propName;
|
return propName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,12 +62,10 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||||
|
|
||||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(lowProperty));
|
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(lowProperty));
|
||||||
if (elProp != null && elProp.containsMany()) {
|
if (elProp != null && elProp.containsMany()) {
|
||||||
manyWhereJoin.add(elProp);
|
manyWhereJoin.add(elProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
elProp = desc.getElPropertyDeploy(name(highProperty));
|
elProp = desc.getElPropertyDeploy(name(highProperty));
|
||||||
if (elProp != null && elProp.containsMany()) {
|
if (elProp != null && elProp.containsMany()) {
|
||||||
manyWhereJoin.add(elProp);
|
manyWhereJoin.add(elProp);
|
||||||
|
|||||||
@@ -9,14 +9,11 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Bitwise expression.
|
* Bitwise expression.
|
||||||
*/
|
*/
|
||||||
class BitwiseExpression extends AbstractExpression {
|
final class BitwiseExpression extends AbstractExpression {
|
||||||
|
|
||||||
protected final BitwiseOp operator;
|
|
||||||
|
|
||||||
|
private final BitwiseOp operator;
|
||||||
private final String compare;
|
private final String compare;
|
||||||
|
private final long flags;
|
||||||
protected final long flags;
|
|
||||||
|
|
||||||
private final long match;
|
private final long match;
|
||||||
|
|
||||||
BitwiseExpression(String propertyName, BitwiseOp operator, long flags, String compare, long match) {
|
BitwiseExpression(String propertyName, BitwiseOp operator, long flags, String compare, long match) {
|
||||||
|
|||||||
+1
-3
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.el.ElPropertyValue;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
final class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
||||||
|
|
||||||
private final boolean not;
|
private final boolean not;
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBindValues(SpiExpressionRequest request) {
|
public void addBindValues(SpiExpressionRequest request) {
|
||||||
|
|
||||||
ElPropertyValue prop = getElProp(request);
|
ElPropertyValue prop = getElProp(request);
|
||||||
if (prop != null && prop.isDbEncrypted()) {
|
if (prop != null && prop.isDbEncrypted()) {
|
||||||
// bind the key as well as the value
|
// bind the key as well as the value
|
||||||
@@ -47,7 +46,6 @@ class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSql(SpiExpressionRequest request) {
|
public void addSql(SpiExpressionRequest request) {
|
||||||
|
|
||||||
String pname = propName;
|
String pname = propName;
|
||||||
ElPropertyValue prop = getElProp(request);
|
ElPropertyValue prop = getElProp(request);
|
||||||
if (prop != null && prop.isDbEncrypted()) {
|
if (prop != null && prop.isDbEncrypted()) {
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ import java.util.ArrayList;
|
|||||||
*
|
*
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*/
|
*/
|
||||||
public class DefaultExampleExpression implements SpiExpression, ExampleExpression {
|
final class DefaultExampleExpression implements SpiExpression, ExampleExpression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The example bean containing the properties.
|
* The example bean containing the properties.
|
||||||
@@ -75,7 +75,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
|||||||
* @param caseInsensitive if true use case insensitive expressions
|
* @param caseInsensitive if true use case insensitive expressions
|
||||||
* @param likeType the type of Like wild card used
|
* @param likeType the type of Like wild card used
|
||||||
*/
|
*/
|
||||||
public DefaultExampleExpression(EntityBean entity, boolean caseInsensitive, LikeType likeType) {
|
DefaultExampleExpression(EntityBean entity, boolean caseInsensitive, LikeType likeType) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.caseInsensitive = caseInsensitive;
|
this.caseInsensitive = caseInsensitive;
|
||||||
this.likeType = likeType;
|
this.likeType = likeType;
|
||||||
|
|||||||
@@ -56,15 +56,10 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
|||||||
private static final String AND = " and ";
|
private static final String AND = " and ";
|
||||||
|
|
||||||
protected List<SpiExpression> list;
|
protected List<SpiExpression> list;
|
||||||
|
|
||||||
protected final Query<T> query;
|
protected final Query<T> query;
|
||||||
|
|
||||||
private final ExpressionList<T> parentExprList;
|
private final ExpressionList<T> parentExprList;
|
||||||
|
|
||||||
protected final ExpressionFactory expr;
|
protected final ExpressionFactory expr;
|
||||||
|
|
||||||
String allDocNestedPath;
|
String allDocNestedPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true for the "Text" root expression list.
|
* Set to true for the "Text" root expression list.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-10
@@ -13,26 +13,17 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DefaultExpressionRequest implements SpiExpressionRequest {
|
public final class DefaultExpressionRequest implements SpiExpressionRequest {
|
||||||
|
|
||||||
private final SpiOrmQueryRequest<?> queryRequest;
|
private final SpiOrmQueryRequest<?> queryRequest;
|
||||||
|
|
||||||
private final BeanDescriptor<?> beanDescriptor;
|
private final BeanDescriptor<?> beanDescriptor;
|
||||||
|
|
||||||
private final StringBuilder sql = new StringBuilder();
|
private final StringBuilder sql = new StringBuilder();
|
||||||
|
|
||||||
private final List<Object> bindValues = new ArrayList<>();
|
private final List<Object> bindValues = new ArrayList<>();
|
||||||
|
|
||||||
private final DeployParser deployParser;
|
private final DeployParser deployParser;
|
||||||
|
|
||||||
private final Binder binder;
|
private final Binder binder;
|
||||||
|
|
||||||
private final SpiExpressionList<?> expressionList;
|
private final SpiExpressionList<?> expressionList;
|
||||||
|
|
||||||
private int paramIndex;
|
private int paramIndex;
|
||||||
|
|
||||||
private final boolean enableBindLog;
|
private final boolean enableBindLog;
|
||||||
|
|
||||||
private StringBuilder bindLog;
|
private StringBuilder bindLog;
|
||||||
|
|
||||||
public DefaultExpressionRequest(SpiOrmQueryRequest<?> queryRequest, DeployParser deployParser, Binder binder, SpiExpressionList<?> expressionList) {
|
public DefaultExpressionRequest(SpiOrmQueryRequest<?> queryRequest, DeployParser deployParser, Binder binder, SpiExpressionList<?> expressionList) {
|
||||||
|
|||||||
+5
-11
@@ -16,15 +16,12 @@ import io.ebeaninternal.server.query.CQuery;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression {
|
final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression {
|
||||||
|
|
||||||
protected final boolean not;
|
private final boolean not;
|
||||||
|
private final SpiQuery<?> subQuery;
|
||||||
protected final SpiQuery<?> subQuery;
|
private List<Object> bindParams;
|
||||||
|
private String sql;
|
||||||
protected List<Object> bindParams;
|
|
||||||
|
|
||||||
protected String sql;
|
|
||||||
|
|
||||||
ExistsQueryExpression(SpiQuery<?> subQuery, boolean not) {
|
ExistsQueryExpression(SpiQuery<?> subQuery, boolean not) {
|
||||||
this.subQuery = subQuery;
|
this.subQuery = subQuery;
|
||||||
@@ -67,7 +64,6 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||||
|
|
||||||
CQuery<?> subQuery = compileSubQuery(request);
|
CQuery<?> subQuery = compileSubQuery(request);
|
||||||
this.bindParams = subQuery.getPredicates().getWhereExprBindValues();
|
this.bindParams = subQuery.getPredicates().getWhereExprBindValues();
|
||||||
this.sql = subQuery.getGeneratedSql().replace('\n', ' ');
|
this.sql = subQuery.getGeneratedSql().replace('\n', ' ');
|
||||||
@@ -99,7 +95,6 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSql(SpiExpressionRequest request) {
|
public void addSql(SpiExpressionRequest request) {
|
||||||
|
|
||||||
if (not) {
|
if (not) {
|
||||||
request.append(" not");
|
request.append(" not");
|
||||||
}
|
}
|
||||||
@@ -110,7 +105,6 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBindValues(SpiExpressionRequest request) {
|
public void addBindValues(SpiExpressionRequest request) {
|
||||||
|
|
||||||
for (Object bindParam : bindParams) {
|
for (Object bindParam : bindParams) {
|
||||||
request.addBindValue(bindParam);
|
request.addBindValue(bindParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.io.Serializable;
|
|||||||
* query that includes the filterMany.
|
* query that includes the filterMany.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class FilterExprPath implements Serializable {
|
public final class FilterExprPath implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6420905565372842018L;
|
private static final long serialVersionUID = -6420905565372842018L;
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -18,14 +18,12 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class FilterExpressionList<T> extends DefaultExpressionList<T> {
|
public final class FilterExpressionList<T> extends DefaultExpressionList<T> {
|
||||||
|
|
||||||
private static final String notAllowedMessage = "This method is not allowed on a filter";
|
private static final String notAllowedMessage = "This method is not allowed on a filter";
|
||||||
|
|
||||||
private final Query<T> rootQuery;
|
private final Query<T> rootQuery;
|
||||||
|
|
||||||
private final FilterExprPath pathPrefix;
|
private final FilterExprPath pathPrefix;
|
||||||
|
|
||||||
private int firstRow;
|
private int firstRow;
|
||||||
private int maxRows;
|
private int maxRows;
|
||||||
private String orderByClause;
|
private String orderByClause;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Slightly redundant as Query.setId() ultimately also does the same job.
|
* Slightly redundant as Query.setId() ultimately also does the same job.
|
||||||
*/
|
*/
|
||||||
class IdExpression extends NonPrepareExpression implements SpiExpression {
|
final class IdExpression extends NonPrepareExpression implements SpiExpression {
|
||||||
|
|
||||||
private final Object value;
|
private final Object value;
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* In a collection of Id values.
|
* In a collection of Id values.
|
||||||
*/
|
*/
|
||||||
public class IdInExpression extends NonPrepareExpression {
|
public final class IdInExpression extends NonPrepareExpression {
|
||||||
|
|
||||||
private final List<Object> idCollection;
|
private final List<Object> idCollection;
|
||||||
|
|
||||||
private boolean multiValueIdSupported;
|
private boolean multiValueIdSupported;
|
||||||
|
|
||||||
public IdInExpression(Collection<?> idCollection) {
|
public IdInExpression(Collection<?> idCollection) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class InExpression extends AbstractExpression {
|
final class InExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean not;
|
private final boolean not;
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,14 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class InPairsExpression extends AbstractExpression {
|
final class InPairsExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean not;
|
private final boolean not;
|
||||||
|
|
||||||
private final String property0, property1;
|
private final String property0, property1;
|
||||||
|
|
||||||
private List<Pairs.Entry> entries;
|
private List<Pairs.Entry> entries;
|
||||||
|
|
||||||
private boolean multiValueSupported;
|
private boolean multiValueSupported;
|
||||||
|
|
||||||
private final String separator;
|
private final String separator;
|
||||||
|
|
||||||
private final String suffix;
|
private final String suffix;
|
||||||
|
|
||||||
private List<Object> concatBindValues;
|
private List<Object> concatBindValues;
|
||||||
|
|
||||||
InPairsExpression(Pairs pairs, boolean not) {
|
InPairsExpression(Pairs pairs, boolean not) {
|
||||||
|
|||||||
@@ -15,14 +15,11 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* In expression using a sub query.
|
* In expression using a sub query.
|
||||||
*/
|
*/
|
||||||
class InQueryExpression extends AbstractExpression implements UnsupportedDocStoreExpression {
|
final class InQueryExpression extends AbstractExpression implements UnsupportedDocStoreExpression {
|
||||||
|
|
||||||
private final boolean not;
|
private final boolean not;
|
||||||
|
|
||||||
private final SpiQuery<?> subQuery;
|
private final SpiQuery<?> subQuery;
|
||||||
|
|
||||||
private List<Object> bindParams;
|
private List<Object> bindParams;
|
||||||
|
|
||||||
private String sql;
|
private String sql;
|
||||||
|
|
||||||
InQueryExpression(String propertyName, SpiQuery<?> subQuery, boolean not) {
|
InQueryExpression(String propertyName, SpiQuery<?> subQuery, boolean not) {
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import io.ebeaninternal.api.SpiExpressionRequest;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class InRangeExpression extends AbstractExpression {
|
final class InRangeExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final Object valueHigh;
|
private final Object valueHigh;
|
||||||
|
|
||||||
private final Object valueLow;
|
private final Object valueLow;
|
||||||
|
|
||||||
InRangeExpression(String propertyName, Object valueLow, Object valueHigh) {
|
InRangeExpression(String propertyName, Object valueLow, Object valueHigh) {
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import io.ebean.util.SplitName;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class IsEmptyExpression extends AbstractExpression {
|
final class IsEmptyExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean empty;
|
private final boolean empty;
|
||||||
|
|
||||||
private final String propertyPath;
|
private final String propertyPath;
|
||||||
|
|
||||||
private String nestedPath;
|
private String nestedPath;
|
||||||
|
|
||||||
IsEmptyExpression(String propertyName, boolean empty) {
|
IsEmptyExpression(String propertyName, boolean empty) {
|
||||||
|
|||||||
@@ -16,27 +16,27 @@ import java.util.Objects;
|
|||||||
* The value passed in is expected to be a valid JSON type so string, number, boolean.
|
* The value passed in is expected to be a valid JSON type so string, number, boolean.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
class JsonPathExpression extends AbstractExpression {
|
final class JsonPathExpression extends AbstractExpression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path in the JSON document in dot notation form.
|
* The path in the JSON document in dot notation form.
|
||||||
*/
|
*/
|
||||||
protected final String path;
|
private final String path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expression operator.
|
* The expression operator.
|
||||||
*/
|
*/
|
||||||
protected final Op operator;
|
private final Op operator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bind value used to compare against the document path value.
|
* The bind value used to compare against the document path value.
|
||||||
*/
|
*/
|
||||||
protected final Object value;
|
private final Object value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Between this is the upper bind value.
|
* For Between this is the upper bind value.
|
||||||
*/
|
*/
|
||||||
protected final Object upperValue;
|
private final Object upperValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct for Operator (not BETWEEN though).
|
* Construct for Operator (not BETWEEN though).
|
||||||
|
|||||||
@@ -48,11 +48,10 @@ import java.util.function.Predicate;
|
|||||||
/**
|
/**
|
||||||
* Junction implementation.
|
* Junction implementation.
|
||||||
*/
|
*/
|
||||||
class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, ExpressionList<T> {
|
final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, ExpressionList<T> {
|
||||||
|
|
||||||
protected DefaultExpressionList<T> exprList;
|
DefaultExpressionList<T> exprList;
|
||||||
|
Junction.Type type;
|
||||||
protected Junction.Type type;
|
|
||||||
|
|
||||||
JunctionExpression(Junction.Type type, Query<T> query, ExpressionList<T> parent) {
|
JunctionExpression(Junction.Type type, Query<T> query, ExpressionList<T> parent) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ import io.ebeaninternal.server.el.ElPropertyValue;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class LikeExpression extends AbstractValueExpression {
|
final class LikeExpression extends AbstractValueExpression {
|
||||||
|
|
||||||
private final boolean caseInsensitive;
|
private final boolean caseInsensitive;
|
||||||
|
|
||||||
private final LikeType type;
|
private final LikeType type;
|
||||||
|
|
||||||
LikeExpression(String propertyName, Object value, boolean caseInsensitive, LikeType type) {
|
LikeExpression(String propertyName, Object value, boolean caseInsensitive, LikeType type) {
|
||||||
@@ -27,7 +26,6 @@ class LikeExpression extends AbstractValueExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBindValues(SpiExpressionRequest request) {
|
public void addBindValues(SpiExpressionRequest request) {
|
||||||
|
|
||||||
ElPropertyValue prop = getElProp(request);
|
ElPropertyValue prop = getElProp(request);
|
||||||
if (prop != null && prop.isDbEncrypted()) {
|
if (prop != null && prop.isDbEncrypted()) {
|
||||||
// bind the key as well as the value
|
// bind the key as well as the value
|
||||||
@@ -40,7 +38,6 @@ class LikeExpression extends AbstractValueExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSql(SpiExpressionRequest request) {
|
public void addSql(SpiExpressionRequest request) {
|
||||||
|
|
||||||
String pname = propName;
|
String pname = propName;
|
||||||
ElPropertyValue prop = getElProp(request);
|
ElPropertyValue prop = getElProp(request);
|
||||||
if (prop != null && prop.isDbEncrypted()) {
|
if (prop != null && prop.isDbEncrypted()) {
|
||||||
@@ -98,7 +95,6 @@ class LikeExpression extends AbstractValueExpression {
|
|||||||
return "%" + value + "%";
|
return "%" + value + "%";
|
||||||
case EQUAL_TO:
|
case EQUAL_TO:
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("LikeType " + type + " missed?");
|
throw new RuntimeException("LikeType " + type + " missed?");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ abstract class LogicExpression implements SpiExpression {
|
|||||||
static final String AND = " and ";
|
static final String AND = " and ";
|
||||||
static final String OR = " or ";
|
static final String OR = " or ";
|
||||||
|
|
||||||
static class And extends LogicExpression {
|
static final class And extends LogicExpression {
|
||||||
|
|
||||||
And(Expression expOne, Expression expTwo) {
|
And(Expression expOne, Expression expTwo) {
|
||||||
super(true, expOne, expTwo);
|
super(true, expOne, expTwo);
|
||||||
@@ -34,7 +34,7 @@ abstract class LogicExpression implements SpiExpression {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Or extends LogicExpression {
|
static final class Or extends LogicExpression {
|
||||||
|
|
||||||
Or(Expression expOne, Expression expTwo) {
|
Or(Expression expOne, Expression expTwo) {
|
||||||
super(false, expOne, expTwo);
|
super(false, expOne, expTwo);
|
||||||
@@ -47,9 +47,7 @@ abstract class LogicExpression implements SpiExpression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpiExpression expOne;
|
SpiExpression expOne;
|
||||||
|
|
||||||
SpiExpression expTwo;
|
SpiExpression expTwo;
|
||||||
|
|
||||||
private final boolean conjunction;
|
private final boolean conjunction;
|
||||||
|
|
||||||
LogicExpression(boolean conjunction, Expression expOne, Expression expTwo) {
|
LogicExpression(boolean conjunction, Expression expOne, Expression expTwo) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Helper for evaluating named parameters.
|
* Helper for evaluating named parameters.
|
||||||
*/
|
*/
|
||||||
class NamedParamHelp {
|
final class NamedParamHelp {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bind value taking into account named parameters.
|
* Return the bind value taking into account named parameters.
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.el.ElPropertyValue;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class NativeILikeExpression extends AbstractExpression {
|
final class NativeILikeExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final String val;
|
private final String val;
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -14,11 +14,10 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Wraps a single expression with nestedPath for document queries.
|
* Wraps a single expression with nestedPath for document queries.
|
||||||
*/
|
*/
|
||||||
class NestedPathWrapperExpression implements SpiExpression {
|
final class NestedPathWrapperExpression implements SpiExpression {
|
||||||
|
|
||||||
protected final String nestedPath;
|
final String nestedPath;
|
||||||
|
final SpiExpression delegate;
|
||||||
protected final SpiExpression delegate;
|
|
||||||
|
|
||||||
NestedPathWrapperExpression(String nestedPath, SpiExpression delegate) {
|
NestedPathWrapperExpression(String nestedPath, SpiExpression delegate) {
|
||||||
this.nestedPath = nestedPath;
|
this.nestedPath = nestedPath;
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Effectively an expression that has no effect.
|
* Effectively an expression that has no effect.
|
||||||
*/
|
*/
|
||||||
class NoopExpression implements SpiExpression {
|
final class NoopExpression implements SpiExpression {
|
||||||
|
|
||||||
protected static final NoopExpression INSTANCE = new NoopExpression();
|
static final NoopExpression INSTANCE = new NoopExpression();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prefixProperty(String path) {
|
public void prefixProperty(String path) {
|
||||||
|
|||||||
@@ -17,14 +17,11 @@ import java.io.IOException;
|
|||||||
* Note that for OneToMany/ManyToMany this effectively gets translated into isEmpty()/isNotEmpty().
|
* Note that for OneToMany/ManyToMany this effectively gets translated into isEmpty()/isNotEmpty().
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
class NullExpression extends AbstractExpression {
|
final class NullExpression extends AbstractExpression {
|
||||||
|
|
||||||
private final boolean notNull;
|
private final boolean notNull;
|
||||||
|
|
||||||
private ElPropertyValue elProperty;
|
private ElPropertyValue elProperty;
|
||||||
|
|
||||||
private boolean assocMany;
|
private boolean assocMany;
|
||||||
|
|
||||||
private String propertyPath;
|
private String propertyPath;
|
||||||
|
|
||||||
NullExpression(String propertyName, boolean notNull) {
|
NullExpression(String propertyName, boolean notNull) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Prepare nested path expressions for
|
* Prepare nested path expressions for
|
||||||
*/
|
*/
|
||||||
class PrepareDocNested {
|
final class PrepareDocNested {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the top level expressions for nested path handling.
|
* Prepare the top level expressions for nested path handling.
|
||||||
|
|||||||
@@ -11,10 +11,9 @@ import io.ebeaninternal.server.persist.MultiValueWrapper;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
class RawExpression extends NonPrepareExpression {
|
final class RawExpression extends NonPrepareExpression {
|
||||||
|
|
||||||
final String sql;
|
final String sql;
|
||||||
|
|
||||||
final Object[] values;
|
final Object[] values;
|
||||||
|
|
||||||
RawExpression(String sql, Object[] values) {
|
RawExpression(String sql, Object[] values) {
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class RawExpressionBuilder {
|
final class RawExpressionBuilder {
|
||||||
|
|
||||||
private static final String BP_1 = "?1";
|
private static final String BP_1 = "?1";
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,26 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* Utility to help isSame methods.
|
* Utility to help isSame methods.
|
||||||
*/
|
*/
|
||||||
public class Same {
|
final class Same {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if both values are null or both an not null.
|
* Return true if both values are null or both an not null.
|
||||||
*/
|
*/
|
||||||
public static boolean sameByNull(Object v1, Object v2) {
|
static boolean sameByNull(Object v1, Object v2) {
|
||||||
return (v1 == null) == (v2 == null);
|
return (v1 == null) == (v2 == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Null safe equals check.
|
* Null safe equals check.
|
||||||
*/
|
*/
|
||||||
public static boolean sameByValue(Object v1, Object v2) {
|
static boolean sameByValue(Object v1, Object v2) {
|
||||||
return Objects.equals(v1, v2);
|
return Objects.equals(v1, v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if both collections are the same by value and order is taken into account.
|
* Return true if both collections are the same by value and order is taken into account.
|
||||||
*/
|
*/
|
||||||
public static boolean sameByValue(Collection<?> v1, Collection<?> v2) {
|
static boolean sameByValue(Collection<?> v1, Collection<?> v2) {
|
||||||
if (v1 == null) {
|
if (v1 == null) {
|
||||||
return v2 == null;
|
return v2 == null;
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,7 @@ public class Same {
|
|||||||
/**
|
/**
|
||||||
* Null safe check by sameByValue or sameByNull based on byValue.
|
* Null safe check by sameByValue or sameByNull based on byValue.
|
||||||
*/
|
*/
|
||||||
public static boolean sameBy(boolean byValue, Object value, Object value1) {
|
static boolean sameBy(boolean byValue, Object value, Object value1) {
|
||||||
|
|
||||||
if (byValue) {
|
if (byValue) {
|
||||||
return sameByValue(value, value1);
|
return sameByValue(value, value1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import io.ebeaninternal.api.NaturalKeyQueryData;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class SimpleExpression extends AbstractValueExpression {
|
public final class SimpleExpression extends AbstractValueExpression {
|
||||||
|
|
||||||
private final Op type;
|
private final Op type;
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -7,10 +7,9 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Full text common terms expression.
|
* Full text common terms expression.
|
||||||
*/
|
*/
|
||||||
class TextCommonTermsExpression extends AbstractTextExpression {
|
final class TextCommonTermsExpression extends AbstractTextExpression {
|
||||||
|
|
||||||
private final String search;
|
private final String search;
|
||||||
|
|
||||||
private final TextCommonTerms options;
|
private final TextCommonTerms options;
|
||||||
|
|
||||||
public TextCommonTermsExpression(String search, TextCommonTerms options) {
|
public TextCommonTermsExpression(String search, TextCommonTerms options) {
|
||||||
|
|||||||
+2
-3
@@ -7,13 +7,12 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Full text MATCH expression.
|
* Full text MATCH expression.
|
||||||
*/
|
*/
|
||||||
public class TextMatchExpression extends AbstractTextExpression {
|
final class TextMatchExpression extends AbstractTextExpression {
|
||||||
|
|
||||||
private final String search;
|
private final String search;
|
||||||
|
|
||||||
private final Match options;
|
private final Match options;
|
||||||
|
|
||||||
public TextMatchExpression(String propertyName, String search, Match options) {
|
TextMatchExpression(String propertyName, String search, Match options) {
|
||||||
super(propertyName);
|
super(propertyName);
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|||||||
+2
-3
@@ -7,13 +7,12 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Full text Multi-Match expression.
|
* Full text Multi-Match expression.
|
||||||
*/
|
*/
|
||||||
public class TextMultiMatchExpression extends AbstractTextExpression {
|
final class TextMultiMatchExpression extends AbstractTextExpression {
|
||||||
|
|
||||||
private final String search;
|
private final String search;
|
||||||
|
|
||||||
private final MultiMatch options;
|
private final MultiMatch options;
|
||||||
|
|
||||||
public TextMultiMatchExpression(String search, MultiMatch options) {
|
TextMultiMatchExpression(String search, MultiMatch options) {
|
||||||
super(null);
|
super(null);
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|||||||
+2
-3
@@ -7,13 +7,12 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Full text query string expression.
|
* Full text query string expression.
|
||||||
*/
|
*/
|
||||||
class TextQueryStringExpression extends AbstractTextExpression {
|
final class TextQueryStringExpression extends AbstractTextExpression {
|
||||||
|
|
||||||
private final String search;
|
private final String search;
|
||||||
|
|
||||||
private final TextQueryString options;
|
private final TextQueryString options;
|
||||||
|
|
||||||
public TextQueryStringExpression(String search, TextQueryString options) {
|
TextQueryStringExpression(String search, TextQueryString options) {
|
||||||
super(null);
|
super(null);
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|||||||
+2
-3
@@ -7,13 +7,12 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Full text Multi-Match expression.
|
* Full text Multi-Match expression.
|
||||||
*/
|
*/
|
||||||
class TextSimpleExpression extends AbstractTextExpression {
|
final class TextSimpleExpression extends AbstractTextExpression {
|
||||||
|
|
||||||
private final String search;
|
private final String search;
|
||||||
|
|
||||||
private final TextSimple options;
|
private final TextSimple options;
|
||||||
|
|
||||||
public TextSimpleExpression(String search, TextSimple options) {
|
TextSimpleExpression(String search, TextSimple options) {
|
||||||
super(null);
|
super(null);
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|||||||
-2
@@ -10,7 +10,6 @@ abstract class BaseDbExpression implements DbExpressionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
||||||
|
|
||||||
String bitOp = bitOp(operator);
|
String bitOp = bitOp(operator);
|
||||||
request.append("(").append(propName).append(" ").append(bitOp).append(" ? ").append(compare).append(" ?)");
|
request.append("(").append(propName).append(" ").append(bitOp).append(" ? ").append(compare).append(" ?)");
|
||||||
}
|
}
|
||||||
@@ -30,7 +29,6 @@ abstract class BaseDbExpression implements DbExpressionHandler {
|
|||||||
* Common alternative where the bitwise operation is a function (specifically bitand is used - H2 and Oracle).
|
* Common alternative where the bitwise operation is a function (specifically bitand is used - H2 and Oracle).
|
||||||
*/
|
*/
|
||||||
protected void bitwiseFunction(SpiExpressionRequest request, String propName, BitwiseOp operator, String compare) {
|
protected void bitwiseFunction(SpiExpressionRequest request, String propName, BitwiseOp operator, String compare) {
|
||||||
|
|
||||||
String funcName = functionName(operator);
|
String funcName = functionName(operator);
|
||||||
request.append(funcName).append("(").append(propName).append(", ?) ").append(compare).append(" ?");
|
request.append(funcName).append("(").append(propName).append(", ?) ").append(compare).append(" ?");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* Not supported JSON or ARRAY expression handler.
|
* Not supported JSON or ARRAY expression handler.
|
||||||
*/
|
*/
|
||||||
public class BasicDbExpression extends BaseDbExpression {
|
class BasicDbExpression extends BaseDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
||||||
|
|||||||
+1
-2
@@ -4,13 +4,12 @@ import io.ebean.annotation.Platform;
|
|||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
|
|
||||||
|
|
||||||
public class DbExpressionHandlerFactory {
|
public final class DbExpressionHandlerFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return the appropriate platform specific handing of expressions.
|
* Create and return the appropriate platform specific handing of expressions.
|
||||||
*/
|
*/
|
||||||
public static DbExpressionHandler from(DatabasePlatform databasePlatform) {
|
public static DbExpressionHandler from(DatabasePlatform databasePlatform) {
|
||||||
|
|
||||||
Platform platform = databasePlatform.getPlatform();
|
Platform platform = databasePlatform.getPlatform();
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case H2:
|
case H2:
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.BitwiseOp;
|
|||||||
/**
|
/**
|
||||||
* H2 handling of platform specific expressions.
|
* H2 handling of platform specific expressions.
|
||||||
*/
|
*/
|
||||||
class H2DbExpression extends BasicDbExpression {
|
final class H2DbExpression extends BasicDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* HANA handling of platform specific expressions.
|
* HANA handling of platform specific expressions.
|
||||||
*/
|
*/
|
||||||
public class HanaDbExpression extends BaseDbExpression {
|
final class HanaDbExpression extends BaseDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* MariaDB specific handling of platform specific expressions.
|
* MariaDB specific handling of platform specific expressions.
|
||||||
*/
|
*/
|
||||||
class MariaDbExpression extends BasicDbExpression {
|
final class MariaDbExpression extends BasicDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* MySql specific handling of platform specific expressions.
|
* MySql specific handling of platform specific expressions.
|
||||||
*/
|
*/
|
||||||
class MySqlDbExpression extends BasicDbExpression {
|
final class MySqlDbExpression extends BasicDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
||||||
|
|||||||
+1
-2
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* Oracle handling of platform specific expressions. ARRAY expressions not supported.
|
* Oracle handling of platform specific expressions. ARRAY expressions not supported.
|
||||||
*/
|
*/
|
||||||
public class OracleDbExpression extends BaseDbExpression {
|
final class OracleDbExpression extends BaseDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String concat(String property0, String separator, String property1, String suffix) {
|
public String concat(String property0, String separator, String property1, String suffix) {
|
||||||
@@ -16,7 +16,6 @@ public class OracleDbExpression extends BaseDbExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
||||||
|
|
||||||
if (operator == Op.EXISTS) {
|
if (operator == Op.EXISTS) {
|
||||||
request.append("json_exists(").append(propName).append(", '$.").append(path).append("')");
|
request.append("json_exists(").append(propName).append(", '$.").append(path).append("')");
|
||||||
} else if (operator == Op.NOT_EXISTS) {
|
} else if (operator == Op.NOT_EXISTS) {
|
||||||
|
|||||||
+3
-4
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.expression.platform;
|
|||||||
/**
|
/**
|
||||||
* Helper for determining type casting for JSON and ARRAY expressions.
|
* Helper for determining type casting for JSON and ARRAY expressions.
|
||||||
*/
|
*/
|
||||||
public class PostgresCast {
|
final class PostgresCast {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postgres CAST the type if necessary.
|
* Postgres CAST the type if necessary.
|
||||||
@@ -11,15 +11,14 @@ public class PostgresCast {
|
|||||||
* This is generally necessary for JSON expressions as text values always returned from the json operators used.
|
* This is generally necessary for JSON expressions as text values always returned from the json operators used.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
protected static String cast(Object value) {
|
static String cast(Object value) {
|
||||||
return cast(value, false);
|
return cast(value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postgres CAST the type if necessary additionally specify if DB ARRAY is used.
|
* Postgres CAST the type if necessary additionally specify if DB ARRAY is used.
|
||||||
*/
|
*/
|
||||||
protected static String cast(Object value, boolean asArray) {
|
static String cast(Object value, boolean asArray) {
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
// for exists and not-exists expressions
|
// for exists and not-exists expressions
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
+1
-4
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* Postgres JSON and ARRAY expression handler
|
* Postgres JSON and ARRAY expression handler
|
||||||
*/
|
*/
|
||||||
public class PostgresDbExpression extends BaseDbExpression {
|
final class PostgresDbExpression extends BaseDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String concat(String property0, String separator, String property1, String suffix) {
|
public String concat(String property0, String separator, String property1, String suffix) {
|
||||||
@@ -15,7 +15,6 @@ public class PostgresDbExpression extends BaseDbExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(50);
|
StringBuilder sb = new StringBuilder(50);
|
||||||
String[] paths = path.split("\\.");
|
String[] paths = path.split("\\.");
|
||||||
if (paths.length == 1) {
|
if (paths.length == 1) {
|
||||||
@@ -41,7 +40,6 @@ public class PostgresDbExpression extends BaseDbExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void arrayContains(SpiExpressionRequest request, String propName, boolean contains, Object... values) {
|
public void arrayContains(SpiExpressionRequest request, String propName, boolean contains, Object... values) {
|
||||||
|
|
||||||
if (!contains) {
|
if (!contains) {
|
||||||
request.append("not (");
|
request.append("not (");
|
||||||
}
|
}
|
||||||
@@ -58,7 +56,6 @@ public class PostgresDbExpression extends BaseDbExpression {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void arrayIsEmpty(SpiExpressionRequest request, String propName, boolean empty) {
|
public void arrayIsEmpty(SpiExpressionRequest request, String propName, boolean empty) {
|
||||||
|
|
||||||
request.append("coalesce(cardinality(").append(propName).append("),0)");
|
request.append("coalesce(cardinality(").append(propName).append("),0)");
|
||||||
if (empty) {
|
if (empty) {
|
||||||
request.append(" = 0");
|
request.append(" = 0");
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.expression.Op;
|
|||||||
/**
|
/**
|
||||||
* Microsoft SQL Server JSON. ARRAY expressions not supported.
|
* Microsoft SQL Server JSON. ARRAY expressions not supported.
|
||||||
*/
|
*/
|
||||||
public class SqlServerDbExpression extends BaseDbExpression {
|
final class SqlServerDbExpression extends BaseDbExpression {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void json(final SpiExpressionRequest request, final String propName,
|
public void json(final SpiExpressionRequest request, final String propName,
|
||||||
|
|||||||
Reference in new issue
Block a user