Class ModelQuery
java.lang.Object
com.onenetwork.platform.data.model.ModelQuery
public class ModelQuery
extends java.lang.Object
Meant to be imported statically to provide methods for creating
filter, sort and retrieval criteria to be used with
ModelDataService.read() to read Models from the database.
See
ModelDataService.read(Class, com.onenetwork.platform.common.usercontext.PlatformUserContext, SqlParams, ModelQueryComponent...)
for more information on how query components can be combined in a read operation.-
Constructor Summary
Constructors Constructor Description ModelQuery()
-
Method Summary
Modifier and Type Method Description static ConcurrencyVersionRetrieval
concurrencyVersionRetrieval()
A marker to define whether the models retrieved should have ConcurrencyVersion transient field set or not.static ModelPaging
paging(long page, long pageSize)
Defines the paging parameters for the model based querystatic ModelRetrieval
retrieve(java.lang.Class<?>... levels)
Selects the levels of a Model to retrievestatic ModelFilter
sqlFilter(java.lang.String sql)
Creates a filter from a SQL fragmentstatic ModelSort
sqlSort(java.lang.String sql)
Creates a sort from a SQL fragment
-
Constructor Details
-
ModelQuery
public ModelQuery()
-
-
Method Details
-
sqlFilter
Creates a filter from a SQL fragment- Parameters:
sql
- SQL fragment to be inserted into the WHERE clause- Returns:
- filter object which can be passed to
ModelDataService.read(Class, com.onenetwork.platform.common.usercontext.PlatformUserContext, SqlParams, ModelQueryComponent...)
-
sqlSort
Creates a sort from a SQL fragment- Parameters:
sql
- SQL fragment to be inserted into the ORDER BY clause- Returns:
- sort object which can be passed to
ModelDataService.read(Class, com.onenetwork.platform.common.usercontext.PlatformUserContext, SqlParams, ModelQueryComponent...)
-
concurrencyVersionRetrieval
A marker to define whether the models retrieved should have ConcurrencyVersion transient field set or not. When this retrieval component is used, the retrieved models and their child level models will be populated with concurrencyVersion transient field with epoch value(Long) which is derived from LastModifiedDate(for top-level models) or LevelModifiedDate(child level models). When an update operation is performed on models with concurrencyVersion set, a check is performed to ensure that the model version to be written in database is not stale and update is always performed on latest version of that model. It can be used to prevent accidental overwrites caused due to stale updates.- Returns:
- concurrencyVersionRetrieval object which can be passed to
ModelDataService.read(Class, com.onenetwork.platform.common.usercontext.PlatformUserContext, SqlParams, ModelQueryComponent...)
-
retrieve
Selects the levels of a Model to retrieve- Parameters:
levels
- levels of a single Model which will be put into the SELECT clause all levels must be from the same model- Returns:
- retrieval object which can be passed to
ModelDataService.read(Class, com.onenetwork.platform.common.usercontext.PlatformUserContext, SqlParams, ModelQueryComponent...)
-
paging
Defines the paging parameters for the model based query- Parameters:
page
- the page number to set. Default page number is 1pageSize
- Sets the number of records per page- Returns:
- paging object to limit the number of rows returned by the model query
-