Package com.atlassian.jira.entity
Class Select
java.lang.Object
com.atlassian.jira.entity.Select
Select is the entry point to building up a
SelectQuery which can be run in OfBiz Entity Engine.
eg
SelectQuery<GenericValue> query = Select.columns().from("FilterSubscription")
.whereEqual("group", (String) null)
.andEqual("username", username)
.orderBy("id desc");
If you are selecting a single column, then you can it can return String objects instead of GenericValues like
SelectQuery<String> query = Select.distinctString("username").from("FilterSubscription");
List<String> vals = query.runWith(delegator).asList();
You can also use an EntityFactory to automatically convert the GenericValues to other entity objects.
List<ProjectCategory> categories = Select.from(Entity.PROJECT_CATEGORY).runWith(delegator).asList();
- Since:
- v5.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPartially constructed query that has enough information supplied to form a complete query.static classA fully specified query that is ready to be executed.static classA partially constructed query with completed column, entity, where condition, and ordering information already specified.static classPartially constructed query that has a column list but no entity name, yet.static classA partially constructed query that may accept.whereand.orderByclauses.static classPartially constructed query that has a column list (with a single target column) but no entity name, yet.static classMarker for contexts that can accept a where clause.static classA partially constructed query that may accept.whereand.orderByclauses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Select.SelectColumnsContextBegins aSELECTquery that will only retrieve the specified columns.static Select.SelectColumnsContextBegins aSELECTquery that will only retrieve the specified columns.static Select.SelectColumnsFromContext<Long>Builds a "SELECT COUNT(*) FROM ..." query for the given entity.static Select.SelectColumnsContextBegins aSELECT DISTINCTquery that will only retrieve the specified columns.distinctString(String columnName) Begins aSELECT DISTINCTquery that will only retrieve the specifiedStringcolumn.static <E> Select.SelectColumnsFromContext<E>from(NamedEntityBuilder<E> entityFactory) Begins aSELECT *query for the specified entity factory.static Select.SelectColumnsFromContext<org.ofbiz.core.entity.GenericValue>Begins aSELECT *query for the specified entity.static Select.SelectSingleColumnContext<Long>id()Begins aSELECTquery that will only retrieve the"id"field, which must useLongvalues.stringColumn(String columnName) Begins aSELECTquery that will only retrieve the specifiedStringcolumn.
-
Constructor Details
-
Select
public Select()
-
-
Method Details
-
columns
Begins aSELECTquery that will only retrieve the specified columns.- Parameters:
columns- the list of fields to retrieve; must not benullor contain anynullvalues- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
columns
Begins aSELECTquery that will only retrieve the specified columns.- Parameters:
columns- the fields to retrieve; must not benullor contain anynullvalues- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
distinct
Begins aSELECT DISTINCTquery that will only retrieve the specified columns.- Parameters:
columns- the fields to retrieve; must not benullor contain anynullvalues- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
id
Begins aSELECTquery that will only retrieve the"id"field, which must useLongvalues.WARNING: Not suitable for use with
"id"columns that return aString, such as those used for issue constants.- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
distinctString
Begins aSELECT DISTINCTquery that will only retrieve the specifiedStringcolumn.- Parameters:
columnName- the field to query- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
stringColumn
Begins aSELECTquery that will only retrieve the specifiedStringcolumn.- Parameters:
columnName- the field to query- Returns:
- a partially constructed query; use
.from(entityName)to continue building it
-
from
Begins aSELECT *query for the specified entity factory.As the query returns results,
EntityBuilder.build(GenericValue)is used on each value to yield its corresponding entity value.- Type Parameters:
E- the entity type that this query will yield, as inferred from its factory- Parameters:
entityFactory- the entity factory to use for covertingGenericValueto the desired return type- Returns:
- a partially constructed query; use one of the
.where...constraints, anorderBy, or a.runWithmethod to continue building it
-
from
public static Select.SelectColumnsFromContext<org.ofbiz.core.entity.GenericValue> from(String entityName) Begins aSELECT *query for the specified entity.- Parameters:
entityName- the name of the entity to query- Returns:
- a partially constructed query; use one of the
.where...constraints, anorderBy, or a.runWithmethod to continue building it
-
countFrom
Builds a "SELECT COUNT(*) FROM ..." query for the given entity.For example:
long count = Select.countFrom(Entity.Name.COMMENT) .whereEqual("author", userKey) .runWith(ofBizDelegator) .singleValue();This method requires the existence of a
"Count"view in the entity model, which has not been defined for all entities. Consider building a normal query with.count()as the finishing action for a more flexible alternative.- Parameters:
entityName- the Entity- Returns:
- a query builder for a "SELECT COUNT(*) FROM ..." query
-