public class QueryBuilder
extends java.lang.Object
StringBuilder
to generate HQL queries.
This comes from the very real deficiencies of the Criteria API when trying to
implement ome.services.SearchBean.
Note: It is the responsibility of each method here to end with a blank space,
meaning that each method may also begin without one.
This class is NOT thread-safe.Constructor and Description |
---|
QueryBuilder() |
QueryBuilder(boolean sqlQuery)
Whether
Session.createSQLQuery(String) should be used or not during
query(Session) and similar. |
QueryBuilder(int size) |
Modifier and Type | Method and Description |
---|---|
QueryBuilder |
and(java.lang.String str)
Appends "and" plus your string unless this is the first where-spec in
which case it is simply appended.
|
QueryBuilder |
append(java.lang.String string)
Simple delegate method to allow appending arbitrary strings.
|
QueryBuilder |
appendSpace() |
void |
delete(java.lang.String table) |
void |
filter(java.lang.String string,
Filter filter) |
QueryBuilder |
filterNow()
In order to support the order() method in addition
to a filter, we allow applying the filter and nulling
the instance eagerly before the user calls order.
|
QueryBuilder |
from(java.lang.String type,
java.lang.String alias) |
QueryBuilder |
join(java.lang.String path,
java.lang.String alias,
boolean outer,
boolean fetch) |
QueryBuilder |
or(java.lang.String str)
Appends "or" plus your string unless this is the first where-spec in
which case it is simply appended.
|
QueryBuilder |
order(java.lang.String path,
boolean ascending) |
QueryBuilder |
param(int id,
java.lang.Object o) |
QueryBuilder |
param(java.lang.String key,
java.lang.Object o) |
QueryBuilder |
paramList(java.lang.String key,
java.util.Collection c) |
void |
params(Parameters params2) |
org.hibernate.Query |
query(org.hibernate.Session session) |
java.lang.String |
queryString()
Returns the current query as a String.
|
org.hibernate.Query |
queryWithoutFilter(org.hibernate.Session session) |
QueryBuilder |
select(java.lang.String... selects) |
QueryBuilder |
skipFrom() |
QueryBuilder |
skipWhere() |
QueryBuilder |
subselect(QueryBuilder subselect)
Appends the string representation of the
QueryBuilder argument
inside of parentheses. |
java.lang.String |
toString() |
java.lang.String |
unique_alias(java.lang.String prefix)
Obtain a unique alias to be used in the SQL.
|
void |
update(java.lang.String table) |
QueryBuilder |
where()
Marks the end of all fetches by adding a "where" clause to the string.
|
QueryBuilder |
whereClause()
Similar to how skipFrom and skipWhere were previously used, this sets
the current builder to
where() but without prefacing the
"where " string. |
public QueryBuilder()
public QueryBuilder(boolean sqlQuery)
Session.createSQLQuery(String)
should be used or not during
query(Session)
and similar.public QueryBuilder(int size)
public java.lang.String unique_alias(java.lang.String prefix)
prefix
- the prefix for the aliaspublic QueryBuilder append(java.lang.String string)
public QueryBuilder select(java.lang.String... selects)
public QueryBuilder from(java.lang.String type, java.lang.String alias)
public QueryBuilder join(java.lang.String path, java.lang.String alias, boolean outer, boolean fetch)
public QueryBuilder where()
public QueryBuilder and(java.lang.String str)
public QueryBuilder or(java.lang.String str)
public QueryBuilder subselect(QueryBuilder subselect)
QueryBuilder
argument
inside of parentheses.public QueryBuilder order(java.lang.String path, boolean ascending)
public QueryBuilder param(int id, java.lang.Object o)
public QueryBuilder param(java.lang.String key, java.lang.Object o)
public QueryBuilder paramList(java.lang.String key, java.util.Collection c)
public QueryBuilder filterNow()
public org.hibernate.Query queryWithoutFilter(org.hibernate.Session session)
public org.hibernate.Query query(org.hibernate.Session session)
public QueryBuilder appendSpace()
public java.lang.String queryString()
toString()
,
this method should return parseable HQL.public java.lang.String toString()
toString
in class java.lang.Object
public void update(java.lang.String table)
public void delete(java.lang.String table)
public QueryBuilder skipFrom()
public QueryBuilder skipWhere()
public QueryBuilder whereClause()
where()
but without prefacing the
"where " string. Instead, it adds a space so that further calls to
where()
also won't add it. This can be used to create a clause
that can later be combined via subselect(QueryBuilder)
.public void filter(java.lang.String string, Filter filter)
public void params(Parameters params2)
Version: 5.4.6-ice35-b87
Copyright © 2018 The University of Dundee & Open Microscopy Environment. All Rights Reserved.