Class RecordLookupHelper
java.lang.Object
com.kingsrook.qqq.backend.core.processes.utils.RecordLookupHelper
Utility to help processes lookup records. Caches lookups - and potentially
can pre-load entire tables or subsets of tables.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorRecordLookupHelper
(boolean useSynchronizedCollections) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetRecordByKey
(String tableName, String keyFieldName, Serializable key) Fetch a record from a table by a key field (doesn't have to be its primary key).getRecordByUniqueKey
(String tableName, Map<String, Serializable> uniqueKey) Fetch a record from a table by a uniqueKey from the tablegetRecordId
(String tableName, String keyFieldName, Serializable key) Get the id (primary key) value from a record, by doing a lookup on the specified keyFieldName, for the specified key value.<T extends Serializable>
TgetRecordId
(String tableName, String keyFieldName, Serializable key, Class<T> type) Get the id (primary key) value from a record, in the requested type, by doing a lookup on the specified keyFieldName, for the specified key value.getRecordValue
(String tableName, String requestedField, String keyFieldName, Serializable key) Get a value from a record, by doing a lookup on the specified keyFieldName, for the specified key value.<T extends Serializable>
TgetRecordValue
(String tableName, String requestedField, String keyFieldName, Serializable key, Class<T> type) Get a value from a record, in the requested type, by doing a lookup on the specified keyFieldName, for the specified key value.void
preloadRecords
(String tableName, String keyFieldName) Optimization - to pre-load the records in a single query, which would otherwise have to be looked up one-by-one.void
preloadRecords
(String tableName, String keyFieldName, QQueryFilter filter) Optimization - to pre-load some records in a single query, which would otherwise have to be looked up one-by-one.preloadRecords
(String tableName, String keyFieldName, List<Serializable> inList) Optimization - to pre-load some records in a single IN-LIST query, which would otherwise have to be looked up one-by-one - where - if the records aren't found, then a null will be cached (for each element in the inList).void
setMayNotDoOneOffLookups
(String tableName, String fieldName)
-
Constructor Details
-
RecordLookupHelper
public RecordLookupHelper()Constructor -
RecordLookupHelper
public RecordLookupHelper(boolean useSynchronizedCollections) Constructor
-
-
Method Details
-
getRecordByUniqueKey
public QRecord getRecordByUniqueKey(String tableName, Map<String, Serializable> uniqueKey) throws QExceptionFetch a record from a table by a uniqueKey from the table- Throws:
QException
-
getRecordByKey
public QRecord getRecordByKey(String tableName, String keyFieldName, Serializable key) throws QException Fetch a record from a table by a key field (doesn't have to be its primary key).- Throws:
QException
-
preloadRecords
Optimization - to pre-load the records in a single query, which would otherwise have to be looked up one-by-one. Note that when this method is called for a given pair of params (table/field), a flag is set to avoid ever re-loading this pair (e.g., subsequent calls to this method w/ a given input pair does a noop).- Throws:
QException
-
preloadRecords
public void preloadRecords(String tableName, String keyFieldName, QQueryFilter filter) throws QException Optimization - to pre-load some records in a single query, which would otherwise have to be looked up one-by-one. Note that this method is different from the overload that doesn't take a filter, in that it doesn't set any flags to avoid re-running (the idea being, you'd pass a unique filter in each time, so you'd always want it to re-run).- Throws:
QException
-
preloadRecords
public Map<Serializable,QRecord> preloadRecords(String tableName, String keyFieldName, List<Serializable> inList) throws QException Optimization - to pre-load some records in a single IN-LIST query, which would otherwise have to be looked up one-by-one - where - if the records aren't found, then a null will be cached (for each element in the inList).- Throws:
QException
-
getRecordValue
public Serializable getRecordValue(String tableName, String requestedField, String keyFieldName, Serializable key) throws QException Get a value from a record, by doing a lookup on the specified keyFieldName, for the specified key value.- Throws:
QException
-
getRecordValue
public <T extends Serializable> T getRecordValue(String tableName, String requestedField, String keyFieldName, Serializable key, Class<T> type) throws QException Get a value from a record, in the requested type, by doing a lookup on the specified keyFieldName, for the specified key value.- Throws:
QException
-
getRecordId
public Serializable getRecordId(String tableName, String keyFieldName, Serializable key) throws QException Get the id (primary key) value from a record, by doing a lookup on the specified keyFieldName, for the specified key value.- Throws:
QException
-
getRecordId
public <T extends Serializable> T getRecordId(String tableName, String keyFieldName, Serializable key, Class<T> type) throws QException Get the id (primary key) value from a record, in the requested type, by doing a lookup on the specified keyFieldName, for the specified key value.- Throws:
QException
-
setMayNotDoOneOffLookups
-