From 559383a810800ac6c81c00cd98fc3bea3290dee2 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Sat, 1 Aug 2015 09:02:34 +1200 Subject: [PATCH] No effective change - format only --- .../server/querydefn/DefaultOrmQuery.java | 4 +- .../server/querydefn/DefaultOrmUpdate.java | 346 ++++++++-------- .../querydefn/DefaultRelationalQuery.java | 384 +++++++++--------- .../server/querydefn/OrmQueryDetail.java | 12 +- .../server/querydefn/OrmQueryProperties.java | 2 +- .../server/querydefn/SimpleTextParser.java | 20 +- 6 files changed, 383 insertions(+), 385 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 10477ceca..0007f1667 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -202,7 +202,7 @@ public class DefaultOrmQuery implements SpiQuery { private boolean autoFetchTuned; private boolean logSecondaryQuery; - + /** * Root table alias. For {@link Query#alias(String)} command. */ @@ -243,7 +243,7 @@ public class DefaultOrmQuery implements SpiQuery { * Additional supply a query which is parsed. */ public DefaultOrmQuery(Class beanType, EbeanServer server, ExpressionFactory expressionFactory, - DeployNamedQuery namedQuery) throws PersistenceException { + DeployNamedQuery namedQuery) throws PersistenceException { this.beanType = beanType; this.server = server; diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java index ac0ab6f02..76fb508c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java @@ -12,204 +12,204 @@ import com.avaje.ebeaninternal.server.deploy.DeployNamedUpdate; */ public final class DefaultOrmUpdate implements SpiUpdate, 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 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. - *

- * 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. - *

- */ - public DefaultOrmUpdate 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 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 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 setNull(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public DefaultOrmUpdate setTimeout(int secs) { + this.timeout = secs; + return this; + } - public DefaultOrmUpdate setNullParameter(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public Class getBeanType() { + return beanType; + } - public DefaultOrmUpdate set(String name, Object value) { - bindParams.setParameter(name, value); - return this; - } + /** + * Return the timeout in seconds. + */ + public int getTimeout() { + return timeout; + } - public DefaultOrmUpdate setParameter(String name, Object param) { - bindParams.setParameter(name, param); - return this; - } + private SpiUpdate.OrmUpdateType deriveType(String updateStatement) { - public DefaultOrmUpdate 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 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. + *

+ * 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. + *

+ */ + public DefaultOrmUpdate 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 set(int position, Object value) { + bindParams.setParameter(position, value); + return this; + } + + public DefaultOrmUpdate setParameter(int position, Object value) { + bindParams.setParameter(position, value); + return this; + } + + public DefaultOrmUpdate setNull(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } + + public DefaultOrmUpdate setNullParameter(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } + + public DefaultOrmUpdate set(String name, Object value) { + bindParams.setParameter(name, value); + return this; + } + + public DefaultOrmUpdate setParameter(String name, Object param) { + bindParams.setParameter(name, param); + return this; + } + + public DefaultOrmUpdate setNull(String name, int jdbcType) { + bindParams.setNullParameter(name, jdbcType); + return this; + } + + public DefaultOrmUpdate 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; - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java index 26680eab8..bcff6ddb7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java @@ -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 findList() { - return server.findList(this, null); - } - - public Set findSet() { - return server.findSet(this, null); - } - - public Map 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 findList() { + return server.findList(this, null); + } + + public Set findSet() { + return server.findSet(this, null); + } + + public Map 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. + *

+ * Note that the returning List Set or Map will be empty. + *

+ */ + 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. - *

- * Note that the returning List Set or Map will be empty. - *

- */ - 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; - } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index bb0d1bee3..b7a2885d8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -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 sorted) { + LinkedHashMap 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 manyChunks = new ArrayList(3); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index 6b084f9c8..a045b4194 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -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 SpiExpressionList filterMany(Query rootQuery) { if (filterMany == null) { FilterExprPath exprPath = new FilterExprPath(path); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java index 4d0ac8f99..d65a24f97 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java @@ -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; } }