Class ValqueriesCrudRepositoryImpl<T,K> 
- All Implemented Interfaces:
- ValqueriesCrudRepository<T,,- K> - CrudRepository<T,- K> 
- Direct Known Subclasses:
- AutoCrudRepositoryImpl,- com.fracturecode.saga.repository.FairLockRepository
- 
Nested Class SummaryNested classes/interfaces inherited from interface io.ran.CrudRepositoryCrudRepository.CrudUpdateResult, CrudRepository.InlineQuery<T,Q extends CrudRepository.InlineQuery<T, Q>> 
- 
Constructor SummaryConstructorsConstructorDescriptionValqueriesCrudRepositoryImpl(ValqueriesRepositoryFactory factory, Class<T> modelType, Class<K> keyType) 
- 
Method SummaryModifier and TypeMethodDescriptiondeleteById(K id) Delete an instance of the entity by its id (primary key).deleteByIds(Collection<K> collection) 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.insert(ITransactionContext tx, Collection<T> entities) Inserts new entries in the database in a transaction.insert(ITransactionContext tx, T entity) 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.<X> XUsed to perform multiple operations in a transaction, ultimately returning a result.protected ValqueriesQuery<T>query()protected ValqueriesQuery<T>protected <O> ValqueriesQuery<O>query(ITransactionContext tx, Class<O> oClass) protected <O> ValqueriesQuery<O>save(ITransactionContext tx, Collection<T> entities) Insert new instances of multiple entities or update existing ones in a transaction.save(ITransactionContext tx, T entity) 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 t, Class<O> oClass) Insert a new instance of another entity or update an existing one in a transaction.saveOthers(ITransactionContext tx, Collection<O> t, Class<O> oClass) Insert new instances of multiple other entities or update existing ones in a transaction.upsert(ITransactionContext tx, Collection<T> t, Consumer<ValqueriesUpsertUpdate<T>> updater) Inserts a new entry or updates an existing entry in the database in a transaction.upsert(Collection<T> t, Consumer<ValqueriesUpsertUpdate<T>> updater) Inserts a new entry or updates an existing entry in the database.
- 
Constructor Details- 
ValqueriesCrudRepositoryImplpublic ValqueriesCrudRepositoryImpl(ValqueriesRepositoryFactory factory, Class<T> modelType, Class<K> keyType) 
 
- 
- 
Method Details- 
getDescription 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 interface- CrudRepository<T,- K> 
- Parameters:
- id- the id of the entity
- Returns:
- an optional containing the entity if it exists
 
- 
getDescription 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 interface- ValqueriesCrudRepository<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
 
- 
getAllDescription copied from interface:CrudRepositoryGet all instances of the entity, as a stream.- Specified by:
- getAllin interface- CrudRepository<T,- K> 
- Returns:
- an unordered stream of all instances of the entity
 
- 
deleteByIdDescription 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 interface- CrudRepository<T,- K> 
- Parameters:
- id- the id of the entity to be deleted
- Returns:
- the result of the delete operation
 
- 
deleteByIdsDescription 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 interface- CrudRepository<T,- K> 
- Parameters:
- collection- a collection of ids to be deleted
- Returns:
- the result of the delete operation
 
- 
saveDescription 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 interface- CrudRepository<T,- K> 
- Parameters:
- entity- the entity to save
- Returns:
- the result of the save operation
 
- 
saveDescription copied from interface:ValqueriesCrudRepositoryInsert a new instance of the entity or update an existing one in a transaction.- Specified by:
- savein interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- entity- the entity to save
- Returns:
- the result of the save operation
 
- 
insertpublic CrudRepository.CrudUpdateResult insert(ITransactionContext tx, T entity) 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 interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- entity- the entity to be inserted
- Returns:
- the result of the insert operation
- Throws:
- ValqueriesInsertFailedException- if the insert statement fails
 
- 
saveDescription copied from interface:ValqueriesCrudRepositoryInsert new instances of multiple entities or update existing ones in a transaction.- Specified by:
- savein interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- entities- the entities to save
- Returns:
- the result of the save operation
 
- 
insertpublic CrudRepository.CrudUpdateResult insert(ITransactionContext tx, Collection<T> entities) 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 interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- entities- the entities to be inserted
- Returns:
- the result of the insert operation
- Throws:
- ValqueriesInsertFailedException- if the insert statement fails
 
- 
saveOtherDescription copied from interface:ValqueriesCrudRepositoryInsert a new instance of another entity or update an existing one in a transaction.- Specified by:
- saveOtherin interface- ValqueriesCrudRepository<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 save
- oClass- the type of the entity
- Returns:
- the result of the save operation
 
- 
insertOtherpublic <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 interface- ValqueriesCrudRepository<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 inserted
- oClass- the type of the entity
- Returns:
- the result of the insert operation
- Throws:
- ValqueriesInsertFailedException- if the insert statement fails
 
- 
saveOtherspublic <O> CrudRepository.CrudUpdateResult saveOthers(ITransactionContext tx, Collection<O> t, Class<O> oClass) Description copied from interface:ValqueriesCrudRepositoryInsert new instances of multiple other entities or update existing ones in a transaction.- Specified by:
- saveOthersin interface- ValqueriesCrudRepository<T,- K> 
- Type Parameters:
- O- the type of the entities
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- t- the entities to save
- oClass- the type of the entities
- Returns:
- the result of the save operation
 
- 
insertOtherspublic <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 interface- ValqueriesCrudRepository<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 inserted
- oClass- the type of the entities
- Returns:
- the result of the insert operation
- Throws:
- ValqueriesInsertFailedException- if the insert statement fails
 
- 
upsertpublic CrudRepository.CrudUpdateResult upsert(Collection<T> t, 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 interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- t- the entities to be upserted
- updater- the function to specify the update operation
- Returns:
- the result of the upsert operation
 
- 
upsertpublic CrudRepository.CrudUpdateResult upsert(ITransactionContext tx, Collection<T> t, 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 interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the transaction context (will be rolled-back if an error occurs)
- t- the entities to be upserted
- updater- the function to specify the update operation
- Returns:
- the result of the upsert operation
 
- 
query
- 
query
- 
query
- 
query
- 
obtainInTransactionDescription copied from interface:ValqueriesCrudRepositoryUsed to perform multiple operations in a transaction, ultimately returning a result.- Specified by:
- obtainInTransactionin interface- ValqueriesCrudRepository<T,- K> 
- Type Parameters:
- X- the type of the result
- Parameters:
- tx- the function to be executed which takes- ITransactionContext
- Returns:
- the result of the function
 
- 
doRetryableInTransactionDescription copied from interface:ValqueriesCrudRepositoryUsed to perform multiple operations in a transaction, with a retry mechanism in case of a transaction deadlock.- Specified by:
- doRetryableInTransactionin interface- ValqueriesCrudRepository<T,- K> 
- Parameters:
- tx- the function to be executed which takes- ITransactionContext
 
 
-