Package com.anylogic.engine.database
- java.lang.Object
- com.anylogic.engine.database.QuerySupport
@AnyLogicInternalAPI public class QuerySupport extends Object
This class is internal and shouldn't be called by user.
it may be removed/renamed in future.
Class supporting query execution.
it may be removed/renamed in future.
Class supporting query execution.
- Author:
- AnyLogic North America, LLC https://anylogic.com
Constructor | Description |
---|---|
QuerySupport |
Modifier and Type | Method | Description |
---|---|---|
static <T> T | castFromDB | |
static Object | castToDB | |
<T> T | fetchResult |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
<R> Object | getCachedValue |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
PreparedStatement | prepareStatement |
Creates a
PreparedStatement object
(which may be used to executes insert, delete and update statements in AnyLogic database)
with the given SQL query string and and fills in the given objects as parameters.Objects passed as parameters are converted automatically to match database format (e.g. |
boolean | selectExists |
Returns
true if the given sql and params returns at least one result
This function caches its results, to speed up default behavior
Use selectExists(false, sql, params) to get non cached result every time |
<T> List<T> | selectValues |
List the results for given sql and params
Given sql query must return single column
An empty list is returned for no results
|
public QuerySupport(ModelDBConnectivity database)
@AnyLogicInternalAPI public static Object castToDB(Object value)
@AnyLogicInternalAPI public static <T> T castFromDB(Object value, Class<T> type)
public PreparedStatement prepareStatement(String sql, Object[] params) throws SQLException
Creates a
Objects passed as parameters are converted automatically to match database format (e.g. option list / enum constants are written as their text names).
Caller is responsible to invoke
PreparedStatement
object
(which may be used to executes insert, delete and update statements in AnyLogic database)
with the given SQL query string and and fills in the given objects as parameters.Objects passed as parameters are converted automatically to match database format (e.g. option list / enum constants are written as their text names).
Caller is responsible to invoke
close()
method on the returned 'prepared statement'
object after usage.- Parameters:
sql
- string containing statementparams
- array containing statement params- Returns:
PreparedStatement
object- Throws:
SQLException
@AnyLogicInternalAPI public <R> Object getCachedValue(com.querydsl.sql.SQLBindings sqlBindings, String operation, Supplier<R> f)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
it may be removed/renamed in future.
public boolean selectExists(boolean cached, String sql, Object... params)
Returns
true
if the given sql and params returns at least one result
This function caches its results, to speed up default behavior
Use selectExists(false, sql, params) to get non cached result every time- Parameters:
cached
- if true, then this method will try to use cached values to avoid database accesssql
- string containing select queryparams
- array containing select query params- Returns:
- the resulting value of column
@AnyLogicInternalAPI public <T> T fetchResult(boolean cached, boolean mustBeUnique, Class<T> returnType, String sql, Object... params)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
it may be removed/renamed in future.
public <T> List<T> selectValues(Class<T> returnType, String sql, Object... params)
List the results for given sql and params
Given sql query must return single column
An empty list is returned for no results
- Parameters:
returnType
- required type of elements returned by this functionsql
- string containing select queryparams
- array containing select query params- Returns:
- List
list of resulting values