mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - remove unused methods and parameters, simplify if
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.core.RelationalQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.util.BeanCollectionFactory;
|
||||
import com.avaje.ebeaninternal.server.util.BeanCollectionParams;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Wraps a BeanCollection with helper methods to add beans.
|
||||
* <p>
|
||||
@@ -73,41 +71,6 @@ public final class BeanCollectionWrapper {
|
||||
this.map = getMap(isMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create based on a Find.
|
||||
*/
|
||||
public BeanCollectionWrapper(OrmQueryRequest<?> request) {
|
||||
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.queryType = request.getQueryType();
|
||||
this.mapKey = request.getQuery().getMapKey();
|
||||
this.isMap = SpiQuery.Type.MAP.equals(queryType);
|
||||
|
||||
this.beanCollection = createBeanCollection(queryType);
|
||||
this.collection = getCollection(isMap);
|
||||
this.map = getMap(isMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create based on a ManyType and mapKey. Note the mapKey is only used if
|
||||
* the manyType is a Map.
|
||||
* <p>
|
||||
* modifyListening is set to true if this is a collection used to hold
|
||||
* ManyToMany associated objects.
|
||||
* </p>
|
||||
*/
|
||||
public BeanCollectionWrapper(BeanPropertyAssocMany<?> manyProp) {
|
||||
|
||||
this.queryType = manyProp.getManyType().getQueryType();
|
||||
this.mapKey = manyProp.getMapKey();
|
||||
this.desc = manyProp.getTargetDescriptor();
|
||||
this.isMap = SpiQuery.Type.MAP.equals(queryType);
|
||||
|
||||
this.beanCollection = createBeanCollection(queryType);
|
||||
this.collection = getCollection(isMap);
|
||||
this.map = getMap(isMap);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private Map<Object,Object> getMap(boolean isMap) {
|
||||
return isMap ? (Map)beanCollection : null;
|
||||
@@ -169,7 +132,7 @@ public final class BeanCollectionWrapper {
|
||||
}
|
||||
rowCount++;
|
||||
if (isMap) {
|
||||
Object keyValue = null;
|
||||
Object keyValue;
|
||||
if (mapKey != null) {
|
||||
// use the value for the property
|
||||
keyValue = desc.getValue(bean, mapKey);
|
||||
|
||||
@@ -485,6 +485,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
|
||||
/**
|
||||
* Read version beans and their effective dates.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Version<T>> readVersions() throws SQLException {
|
||||
|
||||
List<Version<T>> versionList = new ArrayList<Version<T>>();
|
||||
|
||||
@@ -225,7 +225,7 @@ public class CQueryBuilder {
|
||||
queryPlan = new CQueryPlanRawSql(request, res, sqlTree, predicates.getLogWhereSql());
|
||||
|
||||
} else {
|
||||
queryPlan = new CQueryPlan(request, res, sqlTree, rawSql, predicates.getLogWhereSql());
|
||||
queryPlan = new CQueryPlan(request, res, sqlTree, false, predicates.getLogWhereSql());
|
||||
}
|
||||
|
||||
// cache the query plan because we can reuse it and also
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.ValuePair;
|
||||
import com.avaje.ebean.Version;
|
||||
import com.avaje.ebeaninternal.server.core.DiffHelp;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.BeanCollectionTouched;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
@@ -20,10 +10,19 @@ import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebeaninternal.api.BeanIdList;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.core.DiffHelp;
|
||||
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.lib.util.Str;
|
||||
import com.avaje.ebeaninternal.server.persist.Binder;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Handles the Object Relational fetching.
|
||||
@@ -215,7 +214,7 @@ public class CQueryEngine {
|
||||
current = next;
|
||||
}
|
||||
// put an empty map into the last one
|
||||
current.setDiff(Collections.EMPTY_MAP);
|
||||
current.setDiff(new LinkedHashMap<String, ValuePair>());
|
||||
}
|
||||
|
||||
private <T> void deriveVersionDiff(Version<T> current, Version<T> prior, BeanDescriptor<T> descriptor) {
|
||||
|
||||
@@ -48,11 +48,6 @@ public class CQueryPredicates {
|
||||
|
||||
private final Object idValue;
|
||||
|
||||
/**
|
||||
* Flag set if this is a SqlSelect type query.
|
||||
*/
|
||||
private boolean rawSql;
|
||||
|
||||
/**
|
||||
* Named bind parameters.
|
||||
*/
|
||||
@@ -459,10 +454,7 @@ public class CQueryPredicates {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
if (idPos > -1 && idPos < manyPos) {
|
||||
// its all ok, id property appears before a many property
|
||||
|
||||
} else {
|
||||
if (idPos <= -1 || idPos >= manyPos) {
|
||||
if (idPos > manyPos) {
|
||||
// there was an error with the order by...
|
||||
String msg = "A Query on [" + desc + "] includes a join to a 'many' association [" + manyProp.getName();
|
||||
@@ -529,38 +521,8 @@ public class CQueryPredicates {
|
||||
return orderByIncludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The where sql with named bind parameters converted to ?.
|
||||
*/
|
||||
public String getWhereRawSql() {
|
||||
return whereRawSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* The where sql from the expression objects.
|
||||
*/
|
||||
public String getWhereExpressionSql() {
|
||||
return whereExprSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* The having sql with named bind parameters converted to ?.
|
||||
*/
|
||||
public String getHavingRawSql() {
|
||||
return havingRawSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* The having sql from the expression objects.
|
||||
*/
|
||||
public String getHavingExpressionSql() {
|
||||
return havingExprSql;
|
||||
}
|
||||
|
||||
public String getLogWhereSql() {
|
||||
if (rawSql) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (dbWhere == null && dbFilterMany == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.type.DataBind;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Executes the select row count query.
|
||||
*/
|
||||
@@ -100,10 +98,6 @@ public class CQueryRowCount {
|
||||
public String getGeneratedSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public SpiOrmQueryRequest<?> getQueryRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the query returning the row count.
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery.Mode;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.DbReadContext;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* Controls the loading of property data into a bean.
|
||||
* <p>
|
||||
|
||||
@@ -21,10 +21,6 @@ public class SqlTree {
|
||||
*/
|
||||
private final BeanPropertyAssocMany<?> manyProperty;
|
||||
|
||||
private final String manyPropertyName;
|
||||
|
||||
private final ElPropertyValue manyPropEl;
|
||||
|
||||
private final Set<String> includes;
|
||||
|
||||
/**
|
||||
@@ -50,8 +46,7 @@ public class SqlTree {
|
||||
* Create the SqlSelectClause.
|
||||
*/
|
||||
public SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String inheritanceWhereSql,
|
||||
BeanProperty[] encryptedProps, BeanPropertyAssocMany<?> manyProperty, String manyPropertyName,
|
||||
ElPropertyValue manyPropEl, Set<String> includes) {
|
||||
BeanProperty[] encryptedProps, BeanPropertyAssocMany<?> manyProperty, Set<String> includes) {
|
||||
|
||||
this.summary = summary;
|
||||
this.rootNode = rootNode;
|
||||
@@ -60,8 +55,6 @@ public class SqlTree {
|
||||
this.inheritanceWhereSql = inheritanceWhereSql;
|
||||
this.encryptedProps = encryptedProps;
|
||||
this.manyProperty = manyProperty;
|
||||
this.manyPropertyName = manyPropertyName;
|
||||
this.manyPropEl = manyPropEl;
|
||||
this.includes = includes;
|
||||
}
|
||||
|
||||
@@ -76,8 +69,6 @@ public class SqlTree {
|
||||
this.inheritanceWhereSql = null;
|
||||
this.encryptedProps = null;
|
||||
this.manyProperty = null;
|
||||
this.manyPropertyName = null;
|
||||
this.manyPropEl = null;
|
||||
this.includes = null;
|
||||
}
|
||||
|
||||
@@ -141,21 +132,6 @@ public class SqlTree {
|
||||
return manyProperty;
|
||||
}
|
||||
|
||||
public String getManyPropertyName() {
|
||||
return manyPropertyName;
|
||||
}
|
||||
|
||||
public ElPropertyValue getManyPropertyEl() {
|
||||
return manyPropEl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this query includes a Many association.
|
||||
*/
|
||||
public boolean isManyIncluded() {
|
||||
return (manyProperty != null);
|
||||
}
|
||||
|
||||
public BeanProperty[] getEncryptedProps() {
|
||||
return encryptedProps;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ public class SqlTreeBuilder {
|
||||
*/
|
||||
private BeanPropertyAssocMany<?> manyProperty;
|
||||
|
||||
private String manyPropertyName;
|
||||
|
||||
private final SqlTreeAlias alias;
|
||||
|
||||
private final DefaultDbSqlContext ctx;
|
||||
@@ -141,13 +139,8 @@ public class SqlTreeBuilder {
|
||||
encryptedProps = ctx.getEncryptedProps();
|
||||
}
|
||||
|
||||
ElPropertyValue manyPropEl = null;
|
||||
if (manyPropertyName != null) {
|
||||
manyPropEl = desc.getElGetValue(manyPropertyName);
|
||||
}
|
||||
|
||||
return new SqlTree(summary.toString(), rootNode, selectSql, fromSql, inheritanceWhereSql, encryptedProps,
|
||||
manyProperty, manyPropertyName, manyPropEl, queryDetail.getIncludes());
|
||||
manyProperty, queryDetail.getIncludes());
|
||||
}
|
||||
|
||||
private String buildSelectClause() {
|
||||
@@ -213,7 +206,7 @@ public class SqlTreeBuilder {
|
||||
BeanPropertyAssocOne<?>[] ones = desc.propertiesOne();
|
||||
for (int i = 0; i < ones.length; i++) {
|
||||
String propPrefix = SplitName.add(prefix, ones[i].getName());
|
||||
if (isIncludeBean(propPrefix, ones[i])) {
|
||||
if (isIncludeBean(propPrefix)) {
|
||||
selectIncludes.add(propPrefix);
|
||||
buildSelectChain(propPrefix, ones[i], ones[i].getTargetDescriptor(), myJoinList);
|
||||
}
|
||||
@@ -222,7 +215,7 @@ public class SqlTreeBuilder {
|
||||
BeanPropertyAssocMany<?>[] manys = desc.propertiesMany();
|
||||
for (int i = 0; i < manys.length; i++) {
|
||||
String propPrefix = SplitName.add(prefix, manys[i].getName());
|
||||
if (isIncludeMany(prefix, propPrefix, manys[i])) {
|
||||
if (isIncludeMany(propPrefix, manys[i])) {
|
||||
selectIncludes.add(propPrefix);
|
||||
buildSelectChain(propPrefix, manys[i], manys[i].getTargetDescriptor(), myJoinList);
|
||||
}
|
||||
@@ -331,8 +324,7 @@ public class SqlTreeBuilder {
|
||||
* This means it can included individual properties of an embedded bean.
|
||||
* </p>
|
||||
*/
|
||||
private void addPropertyToSubQuery(SqlTreeProperties selectProps, BeanDescriptor<?> desc,
|
||||
OrmQueryProperties queryProps, String propName) {
|
||||
private void addPropertyToSubQuery(SqlTreeProperties selectProps, BeanDescriptor<?> desc, String propName) {
|
||||
|
||||
BeanProperty p = desc.findBeanProperty(propName);
|
||||
if (p == null) {
|
||||
@@ -354,7 +346,7 @@ public class SqlTreeBuilder {
|
||||
OrmQueryProperties queryProps, String propName) {
|
||||
|
||||
if (subQuery) {
|
||||
addPropertyToSubQuery(selectProps, desc, queryProps, propName);
|
||||
addPropertyToSubQuery(selectProps, desc, propName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -472,7 +464,7 @@ public class SqlTreeBuilder {
|
||||
/**
|
||||
* Return true if this many node should be included in the query.
|
||||
*/
|
||||
private boolean isIncludeMany(String prefix, String propName, BeanPropertyAssocMany<?> manyProp) {
|
||||
private boolean isIncludeMany(String propName, BeanPropertyAssocMany<?> manyProp) {
|
||||
|
||||
if (queryDetail.isJoinsEmpty()) {
|
||||
return false;
|
||||
@@ -489,7 +481,6 @@ public class SqlTreeBuilder {
|
||||
}
|
||||
|
||||
manyProperty = manyProp;
|
||||
manyPropertyName = propName;
|
||||
summary.append(" +many:").append(propName);
|
||||
return true;
|
||||
}
|
||||
@@ -504,7 +495,7 @@ public class SqlTreeBuilder {
|
||||
* is added and false is returned.
|
||||
* </p>
|
||||
*/
|
||||
private boolean isIncludeBean(String prefix, BeanPropertyAssocOne<?> prop) {
|
||||
private boolean isIncludeBean(String prefix) {
|
||||
|
||||
if (queryDetail.includes(prefix)) {
|
||||
// explicitly included
|
||||
|
||||
Reference in New Issue
Block a user