AnyLogic
Expand
Font size

@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.
Author:
AnyLogic North America, LLC https://anylogic.com

Constructor Summary

ConstructorDescription
QuerySupport(ModelDBConnectivity database) 

Method Summary

Modifier and TypeMethodDescription
static <T> TcastFromDB(Object value, Class<T> type) 
static ObjectcastToDB(Object value) 
<T> TfetchResult(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.
<R> ObjectgetCachedValue(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.
PreparedStatementprepareStatement(String sql, Object[] params)
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.
booleanselectExists(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
<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

Methods inherited from class java.lang.Object

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

Constructor Details

QuerySupport

public QuerySupport(ModelDBConnectivity database)

Method Details

castToDB

@AnyLogicInternalAPI
public static Object castToDB(Object value)

castFromDB

@AnyLogicInternalAPI
public static <T> T castFromDB(Object value,
 Class<T> type)

prepareStatement

public PreparedStatement prepareStatement(String sql,
 Object[] params)
                                   throws SQLException
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. 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 statement
params - array containing statement params
Returns:
PreparedStatement object
Throws:
SQLException

getCachedValue

@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.

selectExists

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 access
sql - string containing select query
params - array containing select query params
Returns:
the resulting value of column

fetchResult

@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.

selectValues

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 function
sql - string containing select query
params - array containing select query params
Returns:
List list of resulting values