mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - format
This commit is contained in:
@@ -9,8 +9,6 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
/**
|
||||
* Base class for simple expressions.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public abstract class AbstractExpression implements SpiExpression {
|
||||
|
||||
|
||||
@@ -42,10 +42,9 @@ class AllEqualsExpression implements SpiExpression {
|
||||
return;
|
||||
}
|
||||
for (Object value : propMap.values()) {
|
||||
// null value uses is null clause
|
||||
if (value != null) {
|
||||
request.addBindValue(value);
|
||||
} else {
|
||||
// null value uses is null clause
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,8 +58,8 @@ class AllEqualsExpression implements SpiExpression {
|
||||
request.append("(");
|
||||
|
||||
int count = 0;
|
||||
for (Map.Entry<String,Object> entry : propMap.entrySet()) {
|
||||
|
||||
for (Map.Entry<String, Object> entry : propMap.entrySet()) {
|
||||
|
||||
Object value = entry.getValue();
|
||||
String propName = entry.getKey();
|
||||
|
||||
@@ -89,12 +88,12 @@ class AllEqualsExpression implements SpiExpression {
|
||||
|
||||
builder.add(AllEqualsExpression.class);
|
||||
|
||||
for (Entry<String, Object> entry : propMap.entrySet()) {
|
||||
for (Entry<String, Object> entry : propMap.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
String propName = entry.getKey();
|
||||
builder.add(propName).add(value == null ? 0 : 1);
|
||||
builder.bind(value == null ? 0 : 1);
|
||||
}
|
||||
builder.bind(value == null ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
@@ -102,7 +101,7 @@ class AllEqualsExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
|
||||
|
||||
int hc = 31;
|
||||
for (Object value : propMap.values()) {
|
||||
hc = hc * 31 + (value == null ? 0 : value.hashCode());
|
||||
|
||||
@@ -7,42 +7,42 @@ import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
|
||||
class BetweenExpression extends AbstractExpression {
|
||||
|
||||
private static final long serialVersionUID = 2078918165221454910L;
|
||||
private static final long serialVersionUID = 2078918165221454910L;
|
||||
|
||||
private static final String BETWEEN = " between ";
|
||||
|
||||
private final Object valueHigh;
|
||||
|
||||
private final Object valueLow;
|
||||
|
||||
BetweenExpression(String propertyName, Object valLo, Object valHigh) {
|
||||
super(propertyName);
|
||||
this.valueLow = valLo;
|
||||
this.valueHigh = valHigh;
|
||||
}
|
||||
private static final String BETWEEN = " between ";
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
request.addBindValue(valueLow);
|
||||
request.addBindValue(valueHigh);
|
||||
}
|
||||
private final Object valueHigh;
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
request.append(getPropertyName()).append(BETWEEN).append(" ? and ? ");
|
||||
}
|
||||
private final Object valueLow;
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(BetweenExpression.class).add(propName);
|
||||
builder.bind(2);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
int hc = valueLow.hashCode();
|
||||
hc = hc * 31 + valueHigh.hashCode();
|
||||
return hc;
|
||||
}
|
||||
BetweenExpression(String propertyName, Object valLo, Object valHigh) {
|
||||
super(propertyName);
|
||||
this.valueLow = valLo;
|
||||
this.valueHigh = valHigh;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
request.addBindValue(valueLow);
|
||||
request.addBindValue(valueHigh);
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
request.append(getPropertyName()).append(BETWEEN).append(" ? and ? ");
|
||||
}
|
||||
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(BetweenExpression.class).add(propName);
|
||||
builder.bind(2);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
int hc = valueLow.hashCode();
|
||||
hc = hc * 31 + valueHigh.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -215,10 +215,9 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
if (value instanceof String) {
|
||||
list.add(new LikeExpression(propName, (String) value, caseInsensitive, likeType));
|
||||
} else {
|
||||
if (!includeZeros && isZero(value)) {
|
||||
// exclude the zero values typically to weed out
|
||||
// primitive int and long that initialise to 0
|
||||
} else {
|
||||
// exclude the zero values typically to weed out
|
||||
// primitive int and long that initialise to 0
|
||||
if (includeZeros || !isZero(value)) {
|
||||
list.add(new SimpleExpression(propName, SimpleExpression.Op.EQ, value));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
private EntityBean checkEntityBean(Object bean) {
|
||||
if (bean == null || (bean instanceof EntityBean == false)) {
|
||||
if (bean == null || (!(bean instanceof EntityBean))) {
|
||||
throw new IllegalStateException("Expecting an EntityBean");
|
||||
}
|
||||
return (EntityBean)bean;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class ExistsExpression implements SpiExpression {
|
||||
private static final long serialVersionUID = 666990277309851644L;
|
||||
|
||||
private final boolean not;
|
||||
|
||||
private final SpiQuery<?> subQuery;
|
||||
|
||||
private transient CQuery<?> compiledSubQuery;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class FilterExprPath implements Serializable {
|
||||
*/
|
||||
public FilterExprPath trimPath(int prefixTrim) {
|
||||
if (prefixTrim >= path.length()) {
|
||||
return new FilterExprPath(null);
|
||||
return new FilterExprPath(null);
|
||||
}
|
||||
return new FilterExprPath(path.substring(prefixTrim));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class InExpression extends AbstractExpression {
|
||||
|
||||
} else {
|
||||
// extract the id values from the bean
|
||||
Object[] ids = prop.getAssocOneIdValues((EntityBean)values[i]);
|
||||
Object[] ids = prop.getAssocOneIdValues((EntityBean) values[i]);
|
||||
if (ids != null) {
|
||||
for (int j = 0; j < ids.length; j++) {
|
||||
request.addBindValue(ids[j]);
|
||||
|
||||
@@ -11,8 +11,6 @@ import com.avaje.ebeaninternal.server.query.CQuery;
|
||||
|
||||
/**
|
||||
* In expression using a sub query.
|
||||
*
|
||||
* @authors Mario and Rob
|
||||
*/
|
||||
class InQueryExpression extends AbstractExpression {
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
* If true then a disjunction which means outer joins are required.
|
||||
*/
|
||||
private final boolean disjunction;
|
||||
|
||||
|
||||
JunctionExpression(boolean disjunction, String joinType, com.avaje.ebean.Query<T> query, ExpressionList<T> parent) {
|
||||
this.disjunction = disjunction;
|
||||
this.joinType = joinType;
|
||||
@@ -71,7 +71,7 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
// turn on outer joins required for disjunction expressions
|
||||
manyWhereJoin.setRequireOuterJoins(true);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).containsMany(desc, manyWhereJoin);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
public <K> Map<K, T> findMap(String keyProperty, Class<K> keyType) {
|
||||
return exprList.findMap(keyProperty, keyType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PagedList<T> findPagedList(int pageIndex, int pageSize) {
|
||||
return exprList.findPagedList(pageIndex, pageSize);
|
||||
@@ -385,12 +385,12 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> exists(Query<?> subQuery) {
|
||||
return exprList.exists(subQuery);
|
||||
return exprList.exists(subQuery);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> notExists(Query<?> subQuery) {
|
||||
return exprList.exists(subQuery);
|
||||
return exprList.exists(subQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,19 +79,19 @@ class LikeExpression extends AbstractExpression {
|
||||
value = value.toLowerCase();
|
||||
}
|
||||
switch (type) {
|
||||
case RAW:
|
||||
return value;
|
||||
case STARTS_WITH:
|
||||
return value + "%";
|
||||
case ENDS_WITH:
|
||||
return "%" + value;
|
||||
case CONTAINS:
|
||||
return "%" + value + "%";
|
||||
case EQUAL_TO:
|
||||
return value;
|
||||
case RAW:
|
||||
return value;
|
||||
case STARTS_WITH:
|
||||
return value + "%";
|
||||
case ENDS_WITH:
|
||||
return "%" + value;
|
||||
case CONTAINS:
|
||||
return "%" + value + "%";
|
||||
case EQUAL_TO:
|
||||
return value;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("LikeType " + type + " missed?");
|
||||
default:
|
||||
throw new RuntimeException("LikeType " + type + " missed?");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ abstract class LogicExpression implements SpiExpression {
|
||||
* Based on the joinType plus the two expressions.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
expOne.queryAutoFetchHash(builder);
|
||||
expTwo.queryAutoFetchHash(builder);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
builder.add(LogicExpression.class).add(joinType);
|
||||
expOne.queryPlanHash(request, builder);
|
||||
expTwo.queryPlanHash(request, builder);
|
||||
}
|
||||
|
||||
@@ -11,46 +11,46 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
*/
|
||||
class NullExpression extends AbstractExpression {
|
||||
|
||||
private static final long serialVersionUID = 4246991057451128269L;
|
||||
|
||||
private final boolean notNull;
|
||||
|
||||
NullExpression(String propertyName, boolean notNull) {
|
||||
super(propertyName);
|
||||
this.notNull = notNull;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
String propertyName = getPropertyName();
|
||||
private static final long serialVersionUID = 4246991057451128269L;
|
||||
|
||||
String nullExpr = notNull ? " is not null " : " is null ";
|
||||
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isAssocId()){
|
||||
request.append(prop.getAssocOneIdExpr(propertyName, nullExpr));
|
||||
return;
|
||||
}
|
||||
|
||||
request.append(propertyName).append(nullExpr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on notNull flag and the propertyName.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(NullExpression.class).add(notNull).add(propName);
|
||||
}
|
||||
private final boolean notNull;
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return (notNull ? 1 : 0);
|
||||
}
|
||||
NullExpression(String propertyName, boolean notNull) {
|
||||
super(propertyName);
|
||||
this.notNull = notNull;
|
||||
}
|
||||
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
}
|
||||
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
String propertyName = getPropertyName();
|
||||
|
||||
String nullExpr = notNull ? " is not null " : " is null ";
|
||||
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isAssocId()) {
|
||||
request.append(prop.getAssocOneIdExpr(propertyName, nullExpr));
|
||||
return;
|
||||
}
|
||||
|
||||
request.append(propertyName).append(nullExpr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on notNull flag and the propertyName.
|
||||
*/
|
||||
public void queryAutoFetchHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(NullExpression.class).add(notNull).add(propName);
|
||||
}
|
||||
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
queryAutoFetchHash(builder);
|
||||
}
|
||||
|
||||
public int queryBindHash() {
|
||||
return (notNull ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,23 +11,17 @@ public class SimpleExpression extends AbstractExpression {
|
||||
private static final long serialVersionUID = -382881395755603790L;
|
||||
|
||||
enum Op {
|
||||
EQ(" = ? ", " = "), NOT_EQ(" <> ? ", " <> "), LT(" < ? ", " < "), LT_EQ(" <= ? ", " <= "), GT(" > ? ", " > "), GT_EQ(" >= ? ", " >= ");
|
||||
EQ(" = ? "), NOT_EQ(" <> ? "), LT(" < ? "), LT_EQ(" <= ? "), GT(" > ? "), GT_EQ(" >= ? ");
|
||||
|
||||
String exp;
|
||||
String shortDesc;
|
||||
|
||||
Op(String exp, String shortDesc) {
|
||||
Op(String exp) {
|
||||
this.exp = exp;
|
||||
this.shortDesc = shortDesc;
|
||||
}
|
||||
|
||||
public String bind() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public String shortDesc() {
|
||||
return shortDesc;
|
||||
}
|
||||
}
|
||||
|
||||
private final Op type;
|
||||
@@ -61,11 +55,10 @@ public class SimpleExpression extends AbstractExpression {
|
||||
// bind the key as well as the value
|
||||
String encryptKey = prop.getBeanProperty().getEncryptKey().getStringValue();
|
||||
request.addBindValue(encryptKey);
|
||||
} else if (prop.isLocalEncrypted()) {
|
||||
// not supporting this for equals (but probably could)
|
||||
// prop.getBeanProperty().getScalarType();
|
||||
|
||||
}
|
||||
//else if (prop.isLocalEncrypted()) {
|
||||
// not supporting this for equals (but probably could)
|
||||
// prop.getBeanProperty().getScalarType();
|
||||
}
|
||||
|
||||
request.addBindValue(value);
|
||||
|
||||
Reference in New Issue
Block a user