Merge in v4 code changes

This commit is contained in:
Rob Bygrave committed 2014-04-03 03:47:55 +13:00
commit 96e4b4640f
171 files changed
+2747 -3848

No files matched your search

@@ -5,6 +5,7 @@ import java.util.Iterator;
import com.avaje.ebean.ExampleExpression;
import com.avaje.ebean.LikeType;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.ManyWhereJoins;
@@ -43,7 +44,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
/**
* The example bean containing the properties.
*/
private final Object entity;
private final EntityBean entity;
/**
* Set to true to use case insensitive expressions.
@@ -66,6 +67,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
*/
private ArrayList<SpiExpression> list;
/**
* Construct the query by example expression.
*
@@ -181,6 +183,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
for (int i = 0; i < list.size(); i++) {
list.get(i).queryPlanHash(request, builder);
}
return hc;
}
/**
@@ -11,6 +11,7 @@ import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Junction;
import com.avaje.ebean.LikeType;
import com.avaje.ebean.Query;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.api.SpiExpressionFactory;
import com.avaje.ebeaninternal.api.SpiQuery;
@@ -21,6 +22,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
private static final Object[] EMPTY_ARRAY = new Object[] {};
public DefaultExpressionFactory() {
}
@@ -128,11 +130,18 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
return new NullExpression(propertyName, true);
}
private EntityBean checkEntityBean(Object bean) {
if (bean == null || (bean instanceof EntityBean == false)) {
throw new IllegalStateException("Expecting an EntityBean");
}
return (EntityBean)bean;
}
/**
* Case insensitive {@link #exampleLike(Object)}
*/
public ExampleExpression iexampleLike(Object example) {
return new DefaultExampleExpression(example, true, LikeType.RAW);
return new DefaultExampleExpression(checkEntityBean(example), true, LikeType.RAW);
}
/**
@@ -140,14 +149,14 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
* LikeType.RAW (you need to add you own wildcards % and _).
*/
public ExampleExpression exampleLike(Object example) {
return new DefaultExampleExpression(example, false, LikeType.RAW);
return new DefaultExampleExpression(checkEntityBean(example), false, LikeType.RAW);
}
/**
* Create the query by Example expression specifying more options.
*/
public ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) {
return new DefaultExampleExpression(example, caseInsensitive, likeType);
return new DefaultExampleExpression(checkEntityBean(example), caseInsensitive, likeType);
}
/**
@@ -2,6 +2,7 @@ package com.avaje.ebeaninternal.server.expression;
import java.util.Collection;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
@@ -36,7 +37,7 @@ class InExpression extends AbstractExpression {
} else {
// extract the id values from the bean
Object[] ids = prop.getAssocOneIdValues(values[i]);
Object[] ids = prop.getAssocOneIdValues((EntityBean)values[i]);
if (ids != null) {
for (int j = 0; j < ids.length; j++) {
request.addBindValue(ids[j]);
@@ -1,5 +1,6 @@
package com.avaje.ebeaninternal.server.expression;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
@@ -48,7 +49,7 @@ public class SimpleExpression extends AbstractExpression {
ElPropertyValue prop = getElProp(request);
if (prop != null) {
if (prop.isAssocId()) {
Object[] ids = prop.getAssocOneIdValues(value);
Object[] ids = prop.getAssocOneIdValues((EntityBean)value);
if (ids != null) {
for (int i = 0; i < ids.length; i++) {
request.addBindValue(ids[i]);