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
Modifier and TypeClassDescriptionstatic class
Partially constructed query that has enough information supplied to form a complete query.static class
A fully specified query that is ready to be executed.static class
A partially constructed query with completed column, entity, where condition, and ordering information already specified.static class
Partially constructed query that has a column list but no entity name, yet.static class
A partially constructed query that may accept.where
and.orderBy
clauses.static class
Partially constructed query that has a column list (with a single target column) but no entity name, yet.static class
Marker for contexts that can accept a where clause.static class
A partially constructed query that may accept.where
and.orderBy
clauses. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Select.SelectColumnsContext
Begins aSELECT
query that will only retrieve the specified columns.static Select.SelectColumnsContext
Begins aSELECT
query that will only retrieve the specified columns.static Select.SelectColumnsFromContext<Long>
Builds a "SELECT COUNT(*) FROM ..." query for the given entity.static Select.SelectColumnsContext
Begins aSELECT DISTINCT
query that will only retrieve the specified columns.distinctString
(String columnName) Begins aSELECT DISTINCT
query that will only retrieve the specifiedString
column.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 aSELECT
query that will only retrieve the"id"
field, which must useLong
values.stringColumn
(String columnName) Begins aSELECT
query that will only retrieve the specifiedString
column.
-
Constructor Details
-
Select
public Select()
-
-
Method Details
-
columns
Begins aSELECT
query that will only retrieve the specified columns.- Parameters:
columns
- the list of fields to retrieve; must not benull
or contain anynull
values- Returns:
- a partially constructed query; use
.from(entityName)
to continue building it
-
columns
Begins aSELECT
query that will only retrieve the specified columns.- Parameters:
columns
- the fields to retrieve; must not benull
or contain anynull
values- Returns:
- a partially constructed query; use
.from(entityName)
to continue building it
-
distinct
Begins aSELECT DISTINCT
query that will only retrieve the specified columns.- Parameters:
columns
- the fields to retrieve; must not benull
or contain anynull
values- Returns:
- a partially constructed query; use
.from(entityName)
to continue building it
-
id
Begins aSELECT
query that will only retrieve the"id"
field, which must useLong
values.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 DISTINCT
query that will only retrieve the specifiedString
column.- Parameters:
columnName
- the field to query- Returns:
- a partially constructed query; use
.from(entityName)
to continue building it
-
stringColumn
Begins aSELECT
query that will only retrieve the specifiedString
column.- 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 covertingGenericValue
to the desired return type- Returns:
- a partially constructed query; use one of the
.where...
constraints, anorderBy
, or a.runWith
method 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.runWith
method 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
-