mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
No effective change - format only
This commit is contained in:
1 parent
1897ac67a0
commit
559383a810
6 files changed
+383
-385
No files matched your search
+192
-192
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user