No effective change - format only

This commit is contained in:
Robin Bygrave
2015-08-01 09:02:34 +12:00
parent 1897ac67a0
commit 559383a810
6 changed files with 383 additions and 385 deletions
@@ -202,7 +202,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
private boolean autoFetchTuned;
private boolean logSecondaryQuery;
/**
* Root table alias. For {@link Query#alias(String)} command.
*/
@@ -243,7 +243,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
* Additional supply a query which is parsed.
*/
public DefaultOrmQuery(Class<T> beanType, EbeanServer server, ExpressionFactory expressionFactory,
DeployNamedQuery namedQuery) throws PersistenceException {
DeployNamedQuery namedQuery) throws PersistenceException {
this.beanType = beanType;
this.server = server;
@@ -12,204 +12,204 @@ import com.avaje.ebeaninternal.server.deploy.DeployNamedUpdate;
*/
public final class DefaultOrmUpdate<T> implements SpiUpdate<T>, Serializable {
private static final long serialVersionUID = -8791423602246515438L;
private static final long serialVersionUID = -8791423602246515438L;
private transient final EbeanServer server;
private final Class<?> beanType;
/**
* The name of the update.
*/
private final String name;
private transient final EbeanServer server;
/**
* The parameters used to bind to the sql.
*/
private final BindParams bindParams = new BindParams();
private final Class<?> beanType;
/**
* The sql update or delete statement.
*/
private final String updateStatement;
/**
* The name of the update.
*/
private final String name;
/**
* Automatically detect the table being modified by this sql. This will
* register this information so that eBean invalidates cached objects if
* required.
*/
private boolean notifyCache = true;
/**
* The parameters used to bind to the sql.
*/
private final BindParams bindParams = new BindParams();
private int timeout;
private String generatedSql;
private final String baseTable;
private final OrmUpdateType type;
/**
* Create with a specific server. This means you can use the
* UpdateSql.execute() method.
*/
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, String updateStatement) {
this.beanType = beanType;
this.server = server;
this.baseTable = baseTable;
this.name = "";
this.updateStatement = updateStatement;
this.type = deriveType(updateStatement);
/**
* The sql update or delete statement.
*/
private final String updateStatement;
}
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, DeployNamedUpdate namedUpdate) {
this.beanType = beanType;
this.server = server;
this.baseTable = baseTable;
this.name = namedUpdate.getName();
this.notifyCache = namedUpdate.isNotifyCache();
// named updates are always converted to sql as part of the initialisation
this.updateStatement = namedUpdate.getSqlUpdateStatement();
this.type = deriveType(updateStatement);
}
public DefaultOrmUpdate<T> setTimeout(int secs){
this.timeout = secs;
return this;
}
/**
* Automatically detect the table being modified by this sql. This will
* register this information so that eBean invalidates cached objects if
* required.
*/
private boolean notifyCache = true;
public Class<?> getBeanType() {
return beanType;
}
private int timeout;
/**
* Return the timeout in seconds.
*/
public int getTimeout() {
return timeout;
}
private String generatedSql;
private SpiUpdate.OrmUpdateType deriveType(String updateStatement) {
updateStatement = updateStatement.trim();
int spacepos = updateStatement.indexOf(' ');
if (spacepos == -1){
return SpiUpdate.OrmUpdateType.UNKNOWN;
} else {
String firstWord = updateStatement.substring(0, spacepos);
if (firstWord.equalsIgnoreCase("update")){
return SpiUpdate.OrmUpdateType.UPDATE;
} else if (firstWord.equalsIgnoreCase("insert")) {
return SpiUpdate.OrmUpdateType.INSERT;
} else if (firstWord.equalsIgnoreCase("delete")) {
return SpiUpdate.OrmUpdateType.DELETE;
} else {
return SpiUpdate.OrmUpdateType.UNKNOWN;
}
}
}
public int execute() {
return server.execute(this);
}
private final String baseTable;
/**
* Set this to false if you don't want eBean to automatically deduce the
* table modification information and process it.
* <p>
* Set this to false if you don't want any cache invalidation or text index
* management to occur. You may do this when say you update only one column
* and you know that it is not important for cached objects or text indexes.
* </p>
*/
public DefaultOrmUpdate<T> setNotifyCache(boolean notifyCache) {
this.notifyCache = notifyCache;
return this;
}
private final OrmUpdateType type;
/**
* Return true if the cache should be notified so that invalidates
* appropriate objects.
*/
public boolean isNotifyCache() {
return notifyCache;
}
/**
* Create with a specific server. This means you can use the
* UpdateSql.execute() method.
*/
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, String updateStatement) {
this.beanType = beanType;
this.server = server;
this.baseTable = baseTable;
this.name = "";
this.updateStatement = updateStatement;
this.type = deriveType(updateStatement);
public String getName() {
return name;
}
}
public String getUpdateStatement() {
return updateStatement;
}
public DefaultOrmUpdate(Class<?> beanType, EbeanServer server, String baseTable, DeployNamedUpdate namedUpdate) {
public DefaultOrmUpdate<T> set(int position, Object value) {
bindParams.setParameter(position, value);
return this;
}
this.beanType = beanType;
this.server = server;
this.baseTable = baseTable;
this.name = namedUpdate.getName();
this.notifyCache = namedUpdate.isNotifyCache();
public DefaultOrmUpdate<T> setParameter(int position, Object value) {
bindParams.setParameter(position, value);
return this;
}
// named updates are always converted to sql as part of the initialisation
this.updateStatement = namedUpdate.getSqlUpdateStatement();
this.type = deriveType(updateStatement);
}
public DefaultOrmUpdate<T> setNull(int position, int jdbcType) {
bindParams.setNullParameter(position, jdbcType);
return this;
}
public DefaultOrmUpdate<T> setTimeout(int secs) {
this.timeout = secs;
return this;
}
public DefaultOrmUpdate<T> setNullParameter(int position, int jdbcType) {
bindParams.setNullParameter(position, jdbcType);
return this;
}
public Class<?> getBeanType() {
return beanType;
}
public DefaultOrmUpdate<T> set(String name, Object value) {
bindParams.setParameter(name, value);
return this;
}
/**
* Return the timeout in seconds.
*/
public int getTimeout() {
return timeout;
}
public DefaultOrmUpdate<T> setParameter(String name, Object param) {
bindParams.setParameter(name, param);
return this;
}
private SpiUpdate.OrmUpdateType deriveType(String updateStatement) {
public DefaultOrmUpdate<T> setNull(String name, int jdbcType) {
bindParams.setNullParameter(name, jdbcType);
return this;
}
updateStatement = updateStatement.trim();
int spacepos = updateStatement.indexOf(' ');
if (spacepos == -1) {
return SpiUpdate.OrmUpdateType.UNKNOWN;
public DefaultOrmUpdate<T> setNullParameter(String name, int jdbcType) {
bindParams.setNullParameter(name, jdbcType);
return this;
}
} else {
String firstWord = updateStatement.substring(0, spacepos);
if (firstWord.equalsIgnoreCase("update")) {
return SpiUpdate.OrmUpdateType.UPDATE;
/**
* Return the bind parameters.
*/
public BindParams getBindParams() {
return bindParams;
}
} else if (firstWord.equalsIgnoreCase("insert")) {
return SpiUpdate.OrmUpdateType.INSERT;
public String getGeneratedSql() {
return generatedSql;
}
} else if (firstWord.equalsIgnoreCase("delete")) {
return SpiUpdate.OrmUpdateType.DELETE;
} else {
return SpiUpdate.OrmUpdateType.UNKNOWN;
}
}
}
public void setGeneratedSql(String generatedSql) {
this.generatedSql = generatedSql;
}
public int execute() {
return server.execute(this);
}
public String getBaseTable() {
return baseTable;
}
/**
* Set this to false if you don't want eBean to automatically deduce the
* table modification information and process it.
* <p>
* Set this to false if you don't want any cache invalidation or text index
* management to occur. You may do this when say you update only one column
* and you know that it is not important for cached objects or text indexes.
* </p>
*/
public DefaultOrmUpdate<T> setNotifyCache(boolean notifyCache) {
this.notifyCache = notifyCache;
return this;
}
/**
* Return true if the cache should be notified so that invalidates
* appropriate objects.
*/
public boolean isNotifyCache() {
return notifyCache;
}
public String getName() {
return name;
}
public String getUpdateStatement() {
return updateStatement;
}
public DefaultOrmUpdate<T> set(int position, Object value) {
bindParams.setParameter(position, value);
return this;
}
public DefaultOrmUpdate<T> setParameter(int position, Object value) {
bindParams.setParameter(position, value);
return this;
}
public DefaultOrmUpdate<T> setNull(int position, int jdbcType) {
bindParams.setNullParameter(position, jdbcType);
return this;
}
public DefaultOrmUpdate<T> setNullParameter(int position, int jdbcType) {
bindParams.setNullParameter(position, jdbcType);
return this;
}
public DefaultOrmUpdate<T> set(String name, Object value) {
bindParams.setParameter(name, value);
return this;
}
public DefaultOrmUpdate<T> setParameter(String name, Object param) {
bindParams.setParameter(name, param);
return this;
}
public DefaultOrmUpdate<T> setNull(String name, int jdbcType) {
bindParams.setNullParameter(name, jdbcType);
return this;
}
public DefaultOrmUpdate<T> setNullParameter(String name, int jdbcType) {
bindParams.setNullParameter(name, jdbcType);
return this;
}
/**
* Return the bind parameters.
*/
public BindParams getBindParams() {
return bindParams;
}
public String getGeneratedSql() {
return generatedSql;
}
public void setGeneratedSql(String generatedSql) {
this.generatedSql = generatedSql;
}
public String getBaseTable() {
return baseTable;
}
public OrmUpdateType getOrmUpdateType() {
return type;
}
public OrmUpdateType getOrmUpdateType() {
return type;
}
}
@@ -20,208 +20,208 @@ import com.avaje.ebeaninternal.api.SpiSqlQuery;
*/
public class DefaultRelationalQuery implements SpiSqlQuery {
private static final long serialVersionUID = -1098305779779591068L;
private static final long serialVersionUID = -1098305779779591068L;
private final transient EbeanServer server;
private final transient EbeanServer server;
private transient SqlQueryListener queryListener;
private transient SqlQueryListener queryListener;
private String query;
private int firstRow;
private int maxRows;
private String query;
private int timeout;
private boolean futureFetch;
private boolean cancelled;
/**
* For the purposes of cancelling the query.
*/
private transient PreparedStatement pstmt;
/**
* The rows after which the fetch continues in a bg thread.
*/
private int backgroundFetchAfter;
private int firstRow;
private int bufferFetchSizeHint;
/**
* The property used to get the key value for a Map.
*/
private String mapKey;
/**
* Bind parameters when using the query language.
*/
private final BindParams bindParams = new BindParams();
/**
* Additional supply a query detail object.
*/
public DefaultRelationalQuery(EbeanServer server, String query) {
this.server = server;
this.query = query;
}
public DefaultRelationalQuery setQuery(String query) {
this.query = query;
return this;
}
public List<SqlRow> findList() {
return server.findList(this, null);
}
public Set<SqlRow> findSet() {
return server.findSet(this, null);
}
public Map<?,SqlRow> findMap() {
return server.findMap(this, null);
}
public SqlRow findUnique() {
return server.findUnique(this, null);
}
private int maxRows;
public SqlFutureList findFutureList() {
return server.findFutureList(this, null);
}
private int timeout;
public DefaultRelationalQuery setParameter(int position, Object value) {
bindParams.setParameter(position, value);
return this;
private boolean futureFetch;
private boolean cancelled;
/**
* For the purposes of cancelling the query.
*/
private transient PreparedStatement pstmt;
/**
* The rows after which the fetch continues in a bg thread.
*/
private int backgroundFetchAfter;
private int bufferFetchSizeHint;
/**
* The property used to get the key value for a Map.
*/
private String mapKey;
/**
* Bind parameters when using the query language.
*/
private final BindParams bindParams = new BindParams();
/**
* Additional supply a query detail object.
*/
public DefaultRelationalQuery(EbeanServer server, String query) {
this.server = server;
this.query = query;
}
public DefaultRelationalQuery setQuery(String query) {
this.query = query;
return this;
}
public List<SqlRow> findList() {
return server.findList(this, null);
}
public Set<SqlRow> findSet() {
return server.findSet(this, null);
}
public Map<?, SqlRow> findMap() {
return server.findMap(this, null);
}
public SqlRow findUnique() {
return server.findUnique(this, null);
}
public SqlFutureList findFutureList() {
return server.findFutureList(this, null);
}
public DefaultRelationalQuery setParameter(int position, Object value) {
bindParams.setParameter(position, value);
return this;
}
public DefaultRelationalQuery setParameter(String paramName, Object value) {
bindParams.setParameter(paramName, value);
return this;
}
/**
* Return the findListener is one has been set.
*/
public SqlQueryListener getListener() {
return queryListener;
}
/**
* Set a listener. This is designed for large fetches
* where lots are rows are to be processed and instead of
* returning all the rows they are processed one at a time.
* <p>
* Note that the returning List Set or Map will be empty.
* </p>
*/
public DefaultRelationalQuery setListener(SqlQueryListener queryListener) {
this.queryListener = queryListener;
return this;
}
public String toString() {
return "SqlQuery [" + query + "]";
}
public int getFirstRow() {
return firstRow;
}
public DefaultRelationalQuery setFirstRow(int firstRow) {
this.firstRow = firstRow;
return this;
}
public int getMaxRows() {
return maxRows;
}
public DefaultRelationalQuery setMaxRows(int maxRows) {
this.maxRows = maxRows;
return this;
}
public String getMapKey() {
return mapKey;
}
public DefaultRelationalQuery setMapKey(String mapKey) {
this.mapKey = mapKey;
return this;
}
public int getBackgroundFetchAfter() {
return backgroundFetchAfter;
}
public DefaultRelationalQuery setBackgroundFetchAfter(int backgroundFetchAfter) {
this.backgroundFetchAfter = backgroundFetchAfter;
return this;
}
public int getTimeout() {
return timeout;
}
public DefaultRelationalQuery setTimeout(int secs) {
this.timeout = secs;
return this;
}
public BindParams getBindParams() {
return bindParams;
}
public DefaultRelationalQuery setBufferFetchSizeHint(int bufferFetchSizeHint) {
this.bufferFetchSizeHint = bufferFetchSizeHint;
return this;
}
public int getBufferFetchSizeHint() {
return bufferFetchSizeHint;
}
public String getQuery() {
return query;
}
public boolean isFutureFetch() {
return futureFetch;
}
public void setFutureFetch(boolean futureFetch) {
this.futureFetch = futureFetch;
}
public void setPreparedStatement(PreparedStatement pstmt) {
synchronized (this) {
this.pstmt = pstmt;
}
public DefaultRelationalQuery setParameter(String paramName, Object value) {
bindParams.setParameter(paramName, value);
return this;
}
public void cancel() {
synchronized (this) {
this.cancelled = true;
if (pstmt != null) {
try {
pstmt.cancel();
} catch (SQLException e) {
String msg = "Error cancelling query";
throw new PersistenceException(msg, e);
}
}
}
/**
* Return the findListener is one has been set.
*/
public SqlQueryListener getListener() {
return queryListener;
}
}
/**
* Set a listener. This is designed for large fetches
* where lots are rows are to be processed and instead of
* returning all the rows they are processed one at a time.
* <p>
* Note that the returning List Set or Map will be empty.
* </p>
*/
public DefaultRelationalQuery setListener(SqlQueryListener queryListener) {
this.queryListener = queryListener;
return this;
}
public String toString() {
return "SqlQuery ["+query+"]";
public boolean isCancelled() {
synchronized (this) {
return cancelled;
}
public int getFirstRow() {
return firstRow;
}
public DefaultRelationalQuery setFirstRow(int firstRow) {
this.firstRow = firstRow;
return this;
}
public int getMaxRows() {
return maxRows;
}
public DefaultRelationalQuery setMaxRows(int maxRows) {
this.maxRows = maxRows;
return this;
}
public String getMapKey() {
return mapKey;
}
public DefaultRelationalQuery setMapKey(String mapKey) {
this.mapKey = mapKey;
return this;
}
public int getBackgroundFetchAfter() {
return backgroundFetchAfter;
}
public DefaultRelationalQuery setBackgroundFetchAfter(int backgroundFetchAfter) {
this.backgroundFetchAfter = backgroundFetchAfter;
return this;
}
public int getTimeout() {
return timeout;
}
public DefaultRelationalQuery setTimeout(int secs) {
this.timeout = secs;
return this;
}
public BindParams getBindParams() {
return bindParams;
}
public DefaultRelationalQuery setBufferFetchSizeHint(int bufferFetchSizeHint){
this.bufferFetchSizeHint = bufferFetchSizeHint;
return this;
}
public int getBufferFetchSizeHint() {
return bufferFetchSizeHint;
}
public String getQuery() {
return query;
}
public boolean isFutureFetch() {
return futureFetch;
}
public void setFutureFetch(boolean futureFetch) {
this.futureFetch = futureFetch;
}
public void setPreparedStatement(PreparedStatement pstmt){
synchronized (this) {
this.pstmt = pstmt;
}
}
public void cancel() {
synchronized (this) {
this.cancelled = true;
if (pstmt != null){
try {
pstmt.cancel();
} catch (SQLException e) {
String msg = "Error cancelling query";
throw new PersistenceException(msg, e);
}
}
}
}
public boolean isCancelled() {
synchronized (this) {
return cancelled;
}
}
}
}
@@ -252,11 +252,9 @@ public class OrmQueryDetail implements Serializable {
/**
* Set the fetch properties and configuration for a given path.
*
* @param path
* the property to join
* @param partialProps
* the properties on the join property to include
*
* @param path the property to join
* @param partialProps the properties on the join property to include
*/
public void addFetch(String path, String partialProps, FetchConfig fetchConfig) {
@@ -277,7 +275,7 @@ public class OrmQueryDetail implements Serializable {
}
private void sortFetchPaths(BeanDescriptor<?> d, OrmQueryProperties p,
LinkedHashMap<String, OrmQueryProperties> sorted) {
LinkedHashMap<String, OrmQueryProperties> sorted) {
String path = p.getPath();
if (!sorted.containsKey(path)) {
@@ -308,7 +306,7 @@ public class OrmQueryDetail implements Serializable {
* Convert 'fetch joins' to 'many' properties over to 'query joins'.
*/
public void convertManyFetchJoinsToQueryJoins(BeanDescriptor<?> beanDescriptor, String lazyLoadManyPath,
boolean allowOne, int queryBatch) {
boolean allowOne, int queryBatch) {
ArrayList<OrmQueryProperties> manyChunks = new ArrayList<OrmQueryProperties>(3);
@@ -163,7 +163,7 @@ public class OrmQueryProperties implements Serializable {
* Return the expressions used to filter on this path. This should be a many path to use this
* method.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> SpiExpressionList<T> filterMany(Query<T> rootQuery) {
if (filterMany == null) {
FilterExprPath exprPath = new FilterExprPath(path);
@@ -140,17 +140,17 @@ public class SimpleTextParser {
private boolean isOperator(char c) {
switch (c) {
case '<':
return true;
case '>':
return true;
case '=':
return true;
case '!':
return true;
case '<':
return true;
case '>':
return true;
case '=':
return true;
case '!':
return true;
default:
return false;
default:
return false;
}
}