AnyLogic AnyLogic
Expand
Font size
  • java.lang.Object
    • com.anylogic.engine.database.SelectQuery

public class SelectQuery
extends java.lang.Object
SelectQuery for building and execution of SELECT SQL statements

Constructor Summary

Constructors 
SelectQuery​(ModelDatabase database, com.querydsl.sql.RelationalPathBase<?> table, Utilities owner)  
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods 
double[] arrayOfDouble​(com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 1 column with numbers.
int[] arrayOfInt​(com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 1 column with numbers.
long count()
This function caches its results, to speed up default behavior Use count(false) to get non cached result every time
long count​(boolean cached)  
SelectQuery distinct()
Set the SelectQuery to return distinct results
com.querydsl.core.types.dsl.BooleanExpression exists()
Exists is used to test for the existence of any record in a subquery.
com.querydsl.core.Tuple firstResult​(boolean cached, com.querydsl.core.types.Expression<?>... columns)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(columns) to get non cached result every time
<RT> RT firstResult​(boolean cached, com.querydsl.core.types.Expression<RT> column)
Returns first result for the given SelectQuery or null if no result is found
<RT,​T>
RT
firstResult​(boolean cached, com.querydsl.core.types.Expression<T> column, java.lang.Class<RT> returnType)
Returns first result for the given SelectQuery or null if no result is found
com.querydsl.core.Tuple firstResult​(com.querydsl.core.types.Expression<?>... columns)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(columns) to get non cached result every time
<RT> RT firstResult​(com.querydsl.core.types.Expression<RT> column)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(false, column) to get non cached result every time
<RT,​T>
RT
firstResult​(com.querydsl.core.types.Expression<T> column, java.lang.Class<RT> returnType)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(false, column, returnType) to get non cached result every time
SelectQuery fullJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a full join to query
<E> SelectQuery fullJoin​(com.querydsl.sql.ForeignKey<E> key, com.querydsl.sql.RelationalPath<E> table)
Adds a full join to query
com.querydsl.sql.SQLQuery<com.querydsl.core.Tuple> getDSLQuery()  
ResultSet getResults​(com.querydsl.core.types.Expression<?>... columns)
Get the results as an JDBC result set
com.querydsl.sql.SQLBindings getSQL​(com.querydsl.core.types.Expression<?>... columns)
Get the query as an SQL query string and parameters
SelectQuery groupBy​(com.querydsl.core.types.Expression<?> column)
Defines GROUP BY statement column
SelectQuery groupBy​(com.querydsl.core.types.Expression<?>... columns)
Defines GROUP BY statement columns
boolean hasResults()
This function caches its results, to speed up default behavior Use exists(false) to get non cached result every time
boolean hasResults​(boolean cached)  
SelectQuery innerJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds an inner join to query
<E> SelectQuery innerJoin​(com.querydsl.sql.ForeignKey<E> key, com.querydsl.sql.RelationalPath<E> table)
Adds an inner join to query
SelectQuery join​(com.querydsl.core.types.EntityPath<?> table)
Adds a join to query
<E> SelectQuery join​(com.querydsl.sql.ForeignKey<E> key, com.querydsl.sql.RelationalPath<E> table)
Adds a join to query
SelectQuery leftJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a left join to query
<E> SelectQuery leftJoin​(com.querydsl.sql.ForeignKey<E> key, com.querydsl.sql.RelationalPath<E> table)
Adds a left join to query
SelectQuery limit​(long limit)
Defines the maximum number of rows for the selection results
java.util.List<com.querydsl.core.Tuple> list()
List the results for columns of origin table we select from An empty list is returned for no results.
java.util.List<com.querydsl.core.Tuple> list​(com.querydsl.core.types.Expression<?>... columns)
List the results for given columns of SelectQuery An empty list is returned for no results.
<RT> java.util.List<RT> list​(com.querydsl.core.types.Expression<RT> column)
List the results for given column of SelectQuery An empty list is returned for no results.
SelectQuery offset​(long offset)
Defines the offset for the selection results
SelectQuery on​(com.querydsl.core.types.Predicate condition)
Defines a condition to the last added join
SelectQuery on​(com.querydsl.core.types.Predicate... conditions)
Defines a conditions to the last added join
SelectQuery orderBy​(com.querydsl.core.types.OrderSpecifier<?> orderSpecifier)
Defines ORDER BY specifier
SelectQuery orderBy​(com.querydsl.core.types.OrderSpecifier<?>... orderSpecifiers)
Defines ORDER BY specifiers
SelectQuery rightJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a right join to query
<E> SelectQuery rightJoin​(com.querydsl.sql.ForeignKey<E> key, com.querydsl.sql.RelationalPath<E> table)
Adds a right join to query
TableFunction tableFunction​(TableFunction tableFunction, com.querydsl.core.types.Expression<? extends java.lang.Number> argumentColumn, com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 2 columns of data: the first column contains arguments numbers, the second column contains values numbers.
com.querydsl.core.Tuple uniqueResult​(boolean cached, com.querydsl.core.types.Expression<?>... columns)
Returns a unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(columns) to get non cached result every time
<RT> RT uniqueResult​(boolean cached, com.querydsl.core.types.Expression<RT> column)
Returns an unique result for the given SelectQuery
<RT,​T>
RT
uniqueResult​(boolean cached, com.querydsl.core.types.Expression<T> column, java.lang.Class<RT> returnType)
Returns an unique result for the given SelectQuery
com.querydsl.core.Tuple uniqueResult​(com.querydsl.core.types.Expression<?>... columns)
Returns a unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(columns) to get non cached result every time
<RT> RT uniqueResult​(com.querydsl.core.types.Expression<RT> column)
Returns an unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(false, column) to get non cached result every time
<RT,​T>
RT
uniqueResult​(com.querydsl.core.types.Expression<T> column, java.lang.Class<RT> returnType)
Returns an unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(false, column, returnType) to get non cached result every time
SelectQuery where​(com.querydsl.core.types.Predicate condition)
Add condition for selection results
SelectQuery where​(com.querydsl.core.types.Predicate... conditions)
Add conditions for selection results
Modifier and Type Method Description

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

SelectQuery

@AnyLogicInternalAPI
public SelectQuery​(ModelDatabase database,
                   com.querydsl.sql.RelationalPathBase<?> table,
                   Utilities owner)

Method Detail

getDSLQuery

@AnyLogicInternalAPI
public com.querydsl.sql.SQLQuery<com.querydsl.core.Tuple> getDSLQuery()

list

public java.util.List<com.querydsl.core.Tuple> list()
List the results for columns of origin table we select from An empty list is returned for no results.
Returns:
List list of resulting tuples that contain according values

list

public <RT> java.util.List<RT> list​(com.querydsl.core.types.Expression<RT> column)
List the results for given column of SelectQuery An empty list is returned for no results.
Parameters:
column - resulting column
Returns:
List list of resulting values

getSQL

public com.querydsl.sql.SQLBindings getSQL​(com.querydsl.core.types.Expression<?>... columns)
Get the query as an SQL query string and parameters
Parameters:
columns - to select
Returns:
SQLBindings containing SQL query string and its parameters

getResults

public ResultSet getResults​(com.querydsl.core.types.Expression<?>... columns)
Get the results as an JDBC result set
Parameters:
columns - to select
Returns:
selected ResultSet

count

public long count()
This function caches its results, to speed up default behavior Use count(false) to get non cached result every time
Returns:
number of rows matching the given criteria

count

public long count​(boolean cached)
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
Returns:
number of rows matching the given criteria

distinct

public SelectQuery distinct()
Set the SelectQuery to return distinct results
Returns:
SelectQuery

exists

public com.querydsl.core.types.dsl.BooleanExpression exists()
Exists is used to test for the existence of any record in a subquery. To check that there are rows with the given select criteria use hasResults()
Returns:
BooleanExpression

hasResults

public boolean hasResults()
This function caches its results, to speed up default behavior Use exists(false) to get non cached result every time
Returns:
true, if at least one row matching the given criteria exists, otherwise false

hasResults

public boolean hasResults​(boolean cached)
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
Returns:
true, if at least one row matching the given criteria exists, otherwise false

fullJoin

public SelectQuery fullJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a full join to query
Parameters:
table - table to join
Returns:
SelectQuery

fullJoin

public <E> SelectQuery fullJoin​(com.querydsl.sql.ForeignKey<E> key,
                                com.querydsl.sql.RelationalPath<E> table)
Adds a full join to query
Parameters:
key - foreign key to make join
table - table to join
Returns:
SelectQuery

groupBy

public SelectQuery groupBy​(com.querydsl.core.types.Expression<?>... columns)
Defines GROUP BY statement columns
Parameters:
columns - for grouping
Returns:
SelectQuery

groupBy

public SelectQuery groupBy​(com.querydsl.core.types.Expression<?> column)
Defines GROUP BY statement column
Parameters:
column - for grouping
Returns:
SelectQuery

innerJoin

public SelectQuery innerJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds an inner join to query
Parameters:
table - table to join
Returns:
SelectQuery

innerJoin

public <E> SelectQuery innerJoin​(com.querydsl.sql.ForeignKey<E> key,
                                 com.querydsl.sql.RelationalPath<E> table)
Adds an inner join to query
Parameters:
key - foreign key to make join
table - table to join
Returns:
SelectQuery

join

public SelectQuery join​(com.querydsl.core.types.EntityPath<?> table)
Adds a join to query
Parameters:
table - table to join
Returns:
SelectQuery

join

public <E> SelectQuery join​(com.querydsl.sql.ForeignKey<E> key,
                            com.querydsl.sql.RelationalPath<E> table)
Adds a join to query
Parameters:
key - foreign key to make join
table - table to join
Returns:
SelectQuery

leftJoin

public SelectQuery leftJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a left join to query
Parameters:
table - table to join
Returns:
SelectQuery

leftJoin

public <E> SelectQuery leftJoin​(com.querydsl.sql.ForeignKey<E> key,
                                com.querydsl.sql.RelationalPath<E> table)
Adds a left join to query
Parameters:
key - foreign key to make join
table - table to join
Returns:
SelectQuery

limit

public SelectQuery limit​(long limit)
Defines the maximum number of rows for the selection results
Parameters:
limit - maximum number of rows
Returns:
SelectQuery

list

public java.util.List<com.querydsl.core.Tuple> list​(com.querydsl.core.types.Expression<?>... columns)
List the results for given columns of SelectQuery An empty list is returned for no results.
Parameters:
columns - resulting columns
Returns:
List list of resulting tuples that contain according values

offset

public SelectQuery offset​(long offset)
Defines the offset for the selection results
Parameters:
offset -
Returns:
SelectQuery

on

public SelectQuery on​(com.querydsl.core.types.Predicate... conditions)
Defines a conditions to the last added join
Parameters:
conditions -
Returns:
SelectQuery

on

public SelectQuery on​(com.querydsl.core.types.Predicate condition)
Defines a condition to the last added join
Parameters:
conditions -
Returns:
SelectQuery

orderBy

public SelectQuery orderBy​(com.querydsl.core.types.OrderSpecifier<?>... orderSpecifiers)
Defines ORDER BY specifiers
Parameters:
orderSpecifiers - order specifiers ( example: db_table.db_column.asc() )
Returns:
SelectQuery

orderBy

public SelectQuery orderBy​(com.querydsl.core.types.OrderSpecifier<?> orderSpecifier)
Defines ORDER BY specifier
Parameters:
orderSpecifier - order specifier ( example: db_table.db_column.asc() )
Returns:
SelectQuery

rightJoin

public SelectQuery rightJoin​(com.querydsl.core.types.EntityPath<?> table)
Adds a right join to query
Parameters:
table - table to join
Returns:
SelectQuery

rightJoin

public <E> SelectQuery rightJoin​(com.querydsl.sql.ForeignKey<E> key,
                                 com.querydsl.sql.RelationalPath<E> table)
Adds a right join to query
Parameters:
key - foreign key to make join
table - table to join
Returns:
SelectQuery

where

public SelectQuery where​(com.querydsl.core.types.Predicate... conditions)
Add conditions for selection results
Returns:
SelectQuery

where

public SelectQuery where​(com.querydsl.core.types.Predicate condition)
Add condition for selection results
Returns:
SelectQuery

firstResult

public com.querydsl.core.Tuple firstResult​(com.querydsl.core.types.Expression<?>... columns)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(columns) to get non cached result every time
Parameters:
columns - to return as Tuple
Returns:
Tuple containing column values for matching result

uniqueResult

public com.querydsl.core.Tuple uniqueResult​(com.querydsl.core.types.Expression<?>... columns)
Returns a unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(columns) to get non cached result every time
Parameters:
columns - to return as Tuple
Returns:
Tuple containing column values for matching result
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

firstResult

public com.querydsl.core.Tuple firstResult​(boolean cached,
                                           com.querydsl.core.types.Expression<?>... columns)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(columns) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
columns - to return as Tuple
Returns:
Tuple containing column values for matching result

uniqueResult

public com.querydsl.core.Tuple uniqueResult​(boolean cached,
                                            com.querydsl.core.types.Expression<?>... columns)
Returns a unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(columns) to get non cached result every time
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
columns - to return as Tuple
Returns:
Tuple containing column values for matching result
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

firstResult

public <RT,​T> RT firstResult​(com.querydsl.core.types.Expression<T> column,
                                   java.lang.Class<RT> returnType)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(false, column, returnType) to get non cached result every time
Parameters:
column - to return
returnType - type required to be returned by this function
Returns:
the resulting value of column

firstResult

public <RT> RT firstResult​(com.querydsl.core.types.Expression<RT> column)
Returns first result for the given SelectQuery or null if no result is found This function caches its results, to speed up default behavior Use firstResult(false, column) to get non cached result every time
Parameters:
column - to return
Returns:
the resulting value of column

uniqueResult

public <RT,​T> RT uniqueResult​(com.querydsl.core.types.Expression<T> column,
                                    java.lang.Class<RT> returnType)
Returns an unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(false, column, returnType) to get non cached result every time
Parameters:
column - to return
returnType - type required to be returned by this function
Returns:
the resulting value of column
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

uniqueResult

public <RT> RT uniqueResult​(com.querydsl.core.types.Expression<RT> column)
Returns an unique result for the given SelectQuery This function caches its results, to speed up default behavior Use uniqueResult(false, column) to get non cached result every time
Parameters:
column - to return
Returns:
the resulting value of column
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

firstResult

public <RT,​T> RT firstResult​(boolean cached,
                                   com.querydsl.core.types.Expression<T> column,
                                   java.lang.Class<RT> returnType)
Returns first result for the given SelectQuery or null if no result is found
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
column - to return
returnType - type required to be returned by this function
Returns:
the resulting value of column

firstResult

public <RT> RT firstResult​(boolean cached,
                           com.querydsl.core.types.Expression<RT> column)
Returns first result for the given SelectQuery or null if no result is found
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
column - to return
Returns:
the resulting value of column

uniqueResult

public <RT,​T> RT uniqueResult​(boolean cached,
                                    com.querydsl.core.types.Expression<T> column,
                                    java.lang.Class<RT> returnType)
Returns an unique result for the given SelectQuery
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
column - to return
returnType - type required to be returned by this function
Returns:
the resulting value of column
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

uniqueResult

public <RT> RT uniqueResult​(boolean cached,
                            com.querydsl.core.types.Expression<RT> column)
Returns an unique result for the given SelectQuery
Parameters:
cached - if true, then this method will try to use cached values to avoid database access
column - to return
Returns:
the resulting value of column
Throws:
java.lang.RuntimeException - if there is no matching results or more than one matching result

tableFunction

public TableFunction tableFunction​(TableFunction tableFunction,
                                   com.querydsl.core.types.Expression<? extends java.lang.Number> argumentColumn,
                                   com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 2 columns of data: the first column contains arguments numbers, the second column contains values numbers.
Parameters:
tableFunction - the table function to fill
argumentColumn - column with arguments
valueColumn - column with values
Returns:
the given table function, for convenience

arrayOfDouble

public double[] arrayOfDouble​(com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 1 column with numbers. Returns the array of numbers from the column. An empty array is returned for no results
Parameters:
valueColumn - column with values
Returns:
array of 'double' numbers

arrayOfInt

public int[] arrayOfInt​(com.querydsl.core.types.Expression<? extends java.lang.Number> valueColumn)
Executes the given SELECT query which should return 1 column with numbers. Returns the array of numbers from the column. An empty array is returned for no results
Parameters:
valueColumn - column with values
Returns:
array of 'int' numbers
How can we improve this article?