- Enclosing interface:
EntityConnection
public static interface EntityConnection.Select
A class encapsulating select query parameters.
A factory for
EntityConnection.Select.Builder
instances via
all(EntityType)
, where(Condition)
.
// Simple select with condition
List<Entity> metalTracks = connection.select(
Select.where(Track.GENRE_FK.equalTo(metal))
.build()
);
// Complex select with multiple options
List<Entity> tracks = connection.select(
Select.where(Track.ALBUM_FK.equalTo(album))
.orderBy(OrderBy.ascending(Track.TRACKNO))
.attributes(Track.NAME, Track.MILLISECONDS, Track.COMPOSER)
.limit(50)
.referenceDepth(Track.GENRE_FK, 0) // Don't fetch genre
.referenceDepth(Track.MEDIATYPE_FK, 1) // Fetch media type
.build()
);
// Select for update (row locking)
Entity invoice = connection.selectSingle(
Select.where(Invoice.ID.equalTo(invoiceId))
.forUpdate()
.build()
);
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionall
(EntityType entityType) Collection
<Attribute<?>> Returns a map containing the number of levels of foreign key values to fetch per foreign key, with 0 meaning no referenced entities should be fetched, -1 no limit.boolean
having()
limit()
offset()
orderBy()
int
referenceDepth
(ForeignKey foreignKey) Returns the number of levels of foreign key values to fetch, with 0 meaning the referenced entity should not be fetched, -1 no limit and an empty Optional if the global limit should be used (referenceDepth()
).where()
-
Method Details
-
where
Condition where()- Returns:
- the WHERE condition
-
having
Condition having()- Returns:
- the HAVING condition
-
orderBy
- Returns:
- the
OrderBy
for this condition, an empty Optional if none is specified
-
limit
OptionalInt limit()- Returns:
- the LIMIT to use for the given condition, an empty Optional for no limit
-
offset
OptionalInt offset()- Returns:
- the OFFSET to use for the given condition, an empty Optional for no offset
-
forUpdate
boolean forUpdate()- Returns:
- true if this select should lock the result FOR UPDATE
-
queryTimeout
int queryTimeout()- Returns:
- the query timeout
-
referenceDepth
OptionalInt referenceDepth()- Returns:
- the global reference depth limit for this condition, an empty Optional if none has been specified
-
referenceDepth
Returns the number of levels of foreign key values to fetch, with 0 meaning the referenced entity should not be fetched, -1 no limit and an empty Optional if the global limit should be used (referenceDepth()
).- Parameters:
foreignKey
- the foreign key- Returns:
- the number of levels of foreign key values to fetch
-
foreignKeyReferenceDepths
Map<ForeignKey,Integer> foreignKeyReferenceDepths()Returns a map containing the number of levels of foreign key values to fetch per foreign key, with 0 meaning no referenced entities should be fetched, -1 no limit.- Returns:
- a map containing the number of levels of foreign key values to fetch for each foreign key
-
attributes
Collection<Attribute<?>> attributes()- Returns:
- the attributes to include in the query result, an empty Collection if all should be included
-
all
- Parameters:
entityType
- the entity type- Returns:
- a new
EntityConnection.Select.Builder
instance
-
where
- Parameters:
condition
- the WHERE condition- Returns:
- a new
EntityConnection.Select.Builder
instance
-