Class ValqueriesAccessDataLayerImpl<T,K>
- All Implemented Interfaces:
ValqueriesAccessDataLayer<T,,K> ValqueriesCrudRepository<T,,K> CrudRepository<T,,K> CrudRepositoryBaseRepo<T,K, ValqueriesQuery<T>>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ran.CrudRepository
CrudRepository.CrudUpdateResult, CrudRepository.InlineQuery<T,Q extends CrudRepository.InlineQuery<T, Q>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Databaseprotected GenericFactoryprotected MappingHelperprotected TypeDescriber<T> -
Constructor Summary
ConstructorsConstructorDescriptionValqueriesAccessDataLayerImpl(Database database, GenericFactory genericFactory, Class<T> modelType, Class<K> keyType, MappingHelper mappingHelper, DialectFactory dialectFactory) -
Method Summary
Modifier and TypeMethodDescriptiondeleteById(K id) Delete an instance of the entity by its id (primary key).deleteByIds(Collection<K> ids) Delete all instances of the entity which has an id (primary key) in the given collection.voidUsed to perform multiple operations in a transaction, with a retry mechanism in case of a transaction deadlock.get(ITransactionContext tx, K id) Get an instance of the entity by its id in a transaction.Get an instance of the entity by its id (primary key).getAll()Get all instances of the entity, as a stream.protected Thydrate(OrmResultSet row) insert(ITransactionContext tx, Collection<T> ts) Inserts new entries in the database in a transaction.insert(ITransactionContext tx, T t) Inserts a new entry in the database in a transaction.insertOther(ITransactionContext tx, O t, Class<O> oClass) Inserts a new entry of another type in the database in a transaction.insertOthers(ITransactionContext tx, Collection<O> ts, Class<O> oClass) Inserts new entries in the database in a transaction.protected String<X> XUsed to perform multiple operations in a transaction, ultimately returning a result.query()Query for the type of this repository without a transaction.Query for the type of this repository in a transaction.<O> ValqueriesQuery<O>query(ITransactionContext tx, Class<O> oClass) Query for another type in a transaction.<O> ValqueriesQueryImpl<O>Query for another type without a transaction.save(ITransactionContext tx, Collection<T> ts) Insert new instances of multiple entities or update existing ones in a transaction.save(ITransactionContext tx, T t) Insert a new instance of the entity or update an existing one in a transaction.Insert a new instance of the entity or update an existing one.saveOther(ITransactionContext tx, O entity, Class<O> relationClass) Insert a new instance of another entity or update an existing one in a transaction.saveOthers(ITransactionContext tx, Collection<O> entities, Class<O> relationClass) Insert new instances of multiple other entities or update existing ones in a transaction.upsert(ITransactionContext tx, Collection<T> ts, Consumer<ValqueriesUpsertUpdate<T>> updater) Inserts a new entry or updates an existing entry in the database in a transaction.upsert(Collection<T> ts, Consumer<ValqueriesUpsertUpdate<T>> updater) Inserts a new entry or updates an existing entry in the database.
-
Field Details
-
database
-
genericFactory
-
modelType
-
keyType
-
typeDescriber
-
mappingHelper
-
-
Constructor Details
-
ValqueriesAccessDataLayerImpl
public ValqueriesAccessDataLayerImpl(Database database, GenericFactory genericFactory, Class<T> modelType, Class<K> keyType, MappingHelper mappingHelper, DialectFactory dialectFactory)
-
-
Method Details
-
keyColumn
-
hydrate
-
get
Description copied from interface:CrudRepositoryGet an instance of the entity by its id (primary key).Note: If the entity does not have a primary key, this method will not be available.
In case of compound primary key, pass the model object with the primary key fields populated.
- Specified by:
getin interfaceCrudRepository<T,K> - Parameters:
id- the id of the entity- Returns:
- an optional containing the entity if it exists
-
get
Description copied from interface:ValqueriesCrudRepositoryGet an instance of the entity by its id in a transaction.Note: If the entity does not have a primary key, this method will not be available.
- Specified by:
getin interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)id- the id of the entity- Returns:
- an optional containing the entity if it exists
-
getAll
Description copied from interface:CrudRepositoryGet all instances of the entity, as a stream.- Specified by:
getAllin interfaceCrudRepository<T,K> - Returns:
- an unordered stream of all instances of the entity
-
deleteById
Description copied from interface:CrudRepositoryDelete an instance of the entity by its id (primary key).Note: If the entity does not have a primary key, this method will not be available.
In case of compound primary key, pass the model object with the primary key fields populated.
- Specified by:
deleteByIdin interfaceCrudRepository<T,K> - Parameters:
id- the id of the entity to be deleted- Returns:
- the result of the delete operation
-
deleteByIds
Description copied from interface:CrudRepositoryDelete all instances of the entity which has an id (primary key) in the given collection.Note: If the entity does not have a primary key, this method will not be available.
In case of compound primary key, pass the model object with the primary key fields populated.
- Specified by:
deleteByIdsin interfaceCrudRepository<T,K> - Parameters:
ids- a collection of ids to be deleted- Returns:
- the result of the delete operation
-
save
Description copied from interface:CrudRepositoryInsert a new instance of the entity or update an existing one. Will match by primary key, but not other unique keys.- Specified by:
savein interfaceCrudRepository<T,K> - Parameters:
t- the entity to save- Returns:
- the result of the save operation
-
save
Description copied from interface:ValqueriesCrudRepositoryInsert a new instance of the entity or update an existing one in a transaction.- Specified by:
savein interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)t- the entity to save- Returns:
- the result of the save operation
-
insert
public CrudRepository.CrudUpdateResult insert(ITransactionContext tx, T t) throws ValqueriesInsertFailedException Description copied from interface:ValqueriesCrudRepositoryInserts a new entry in the database in a transaction. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.- Specified by:
insertin interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)t- the entity to be inserted- Returns:
- the result of the insert operation
- Throws:
ValqueriesInsertFailedException- if the insert statement fails
-
save
Description copied from interface:ValqueriesCrudRepositoryInsert new instances of multiple entities or update existing ones in a transaction.- Specified by:
savein interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)ts- the entities to save- Returns:
- the result of the save operation
-
insert
public CrudRepository.CrudUpdateResult insert(ITransactionContext tx, Collection<T> ts) throws ValqueriesInsertFailedException Description copied from interface:ValqueriesCrudRepositoryInserts new entries in the database in a transaction. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.- Specified by:
insertin interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)ts- the entities to be inserted- Returns:
- the result of the insert operation
- Throws:
ValqueriesInsertFailedException- if the insert statement fails
-
saveOther
public <O> CrudRepository.CrudUpdateResult saveOther(ITransactionContext tx, O entity, Class<O> relationClass) Description copied from interface:ValqueriesCrudRepositoryInsert a new instance of another entity or update an existing one in a transaction.- Specified by:
saveOtherin interfaceValqueriesCrudRepository<T,K> - Type Parameters:
O- the type of the entity- Parameters:
tx- the transaction context (will be rolled-back if an error occurs)entity- the entity to saverelationClass- the type of the entity- Returns:
- the result of the save operation
-
insertOther
public <O> CrudRepository.CrudUpdateResult insertOther(ITransactionContext tx, O t, Class<O> oClass) throws ValqueriesInsertFailedException Description copied from interface:ValqueriesCrudRepositoryInserts a new entry of another type in the database in a transaction. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.- Specified by:
insertOtherin interfaceValqueriesCrudRepository<T,K> - Type Parameters:
O- the type of the entity- Parameters:
tx- the transaction context (will be rolled-back if an error occurs)t- the entity to be insertedoClass- the type of the entity- Returns:
- the result of the insert operation
- Throws:
ValqueriesInsertFailedException- if the insert statement fails
-
saveOthers
public <O> CrudRepository.CrudUpdateResult saveOthers(ITransactionContext tx, Collection<O> entities, Class<O> relationClass) Description copied from interface:ValqueriesCrudRepositoryInsert new instances of multiple other entities or update existing ones in a transaction.- Specified by:
saveOthersin interfaceValqueriesCrudRepository<T,K> - Type Parameters:
O- the type of the entities- Parameters:
tx- the transaction context (will be rolled-back if an error occurs)entities- the entities to saverelationClass- the type of the entities- Returns:
- the result of the save operation
-
insertOthers
public <O> CrudRepository.CrudUpdateResult insertOthers(ITransactionContext tx, Collection<O> ts, Class<O> oClass) throws ValqueriesInsertFailedException Description copied from interface:ValqueriesCrudRepositoryInserts new entries in the database in a transaction. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.- Specified by:
insertOthersin interfaceValqueriesCrudRepository<T,K> - Type Parameters:
O- the type of the entities- Parameters:
tx- the transaction context (will be rolled-back if an error occurs)ts- the entities to be insertedoClass- the type of the entities- Returns:
- the result of the insert operation
- Throws:
ValqueriesInsertFailedException- if the insert statement fails
-
upsert
public CrudRepository.CrudUpdateResult upsert(Collection<T> ts, Consumer<ValqueriesUpsertUpdate<T>> updater) Description copied from interface:ValqueriesCrudRepositoryInserts a new entry or updates an existing entry in the database. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.You can use this method instead of
CrudRepository.save(Object)if you need a custom update operation. Existing fields are matched based on any key, primary or unique. If the primary key is auto-increment, its value has to be `null` and at least one unique key needs to exist. If existing entry is not matched, the entry will be inserted as is. If existing entry is matched, only the fields that are set by the updater argument will be updated.Due to different behavior of supported database vendors, case where multiple upserted entities match the same row in the database is not supported, and case where one upserted entity matches multiple rows in the database will result in update of at least one of the rows. If the primary key is auto-increment and only one entity is being upserted, the primary key of the entity will be set to the value of the inserted / updated row.
- Specified by:
upsertin interfaceValqueriesCrudRepository<T,K> - Parameters:
ts- the entities to be upsertedupdater- the function to specify the update operation- Returns:
- the result of the upsert operation
-
upsert
public CrudRepository.CrudUpdateResult upsert(ITransactionContext tx, Collection<T> ts, Consumer<ValqueriesUpsertUpdate<T>> updater) Description copied from interface:ValqueriesCrudRepositoryInserts a new entry or updates an existing entry in the database in a transaction. Important to notice: noRelationwill be persisted. If the entity to be inserted contains relations, they will have to be inserted manually.You can use this method instead of
ValqueriesCrudRepository.save(ITransactionContext, T)if you need a custom update operation. Existing fields are matched based on any key, primary or unique. If the primary key is auto-increment, its value has to be `null` and at least one unique key needs to exist. If existing entry is not matched, the entry will be inserted as is. If existing entry is matched, only the fields that are set by the updater argument will be updated.Due to different behavior of supported database vendors, case where multiple upserted entities match the same row in the database is not supported, and case where one upserted entity matches multiple rows in the database will result in update of at least one of the rows. If the primary key is auto-increment and only one entity is being upserted, the primary key of the entity will be set to the value of the inserted / updated row.
- Specified by:
upsertin interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)ts- the entities to be upsertedupdater- the function to specify the update operation- Returns:
- the result of the upsert operation
-
query
Description copied from interface:CrudRepositoryBaseRepoQuery for the type of this repository without a transaction.- Specified by:
queryin interfaceCrudRepositoryBaseRepo<T,K, ValqueriesQuery<T>> - Returns:
- a new query for this repository
-
query
Description copied from interface:ValqueriesAccessDataLayerQuery for another type without a transaction.- Specified by:
queryin interfaceValqueriesAccessDataLayer<T,K> - Type Parameters:
O- the type to be queried- Parameters:
oClass- the type to be queried- Returns:
- a new query for the specified type
-
query
Description copied from interface:ValqueriesAccessDataLayerQuery for the type of this repository in a transaction.- Specified by:
queryin interfaceValqueriesAccessDataLayer<T,K> - Parameters:
tx- the transaction context (will be rolled-back if an error occurs)- Returns:
- a new query for this repository in a transaction
-
query
Description copied from interface:ValqueriesAccessDataLayerQuery for another type in a transaction.- Specified by:
queryin interfaceValqueriesAccessDataLayer<T,K> - Type Parameters:
O- the type to be queried- Parameters:
tx- the transaction context (will be rolled-back if an error occurs)oClass- the type to be queried- Returns:
- a new query for the specified type in a transaction
-
obtainInTransaction
Description copied from interface:ValqueriesCrudRepositoryUsed to perform multiple operations in a transaction, ultimately returning a result.- Specified by:
obtainInTransactionin interfaceValqueriesCrudRepository<T,K> - Type Parameters:
X- the type of the result- Parameters:
tx- the function to be executed which takesITransactionContext- Returns:
- the result of the function
-
doRetryableInTransaction
Description copied from interface:ValqueriesCrudRepositoryUsed to perform multiple operations in a transaction, with a retry mechanism in case of a transaction deadlock.- Specified by:
doRetryableInTransactionin interfaceValqueriesCrudRepository<T,K> - Parameters:
tx- the function to be executed which takesITransactionContext
-