Package org.fryske_akademy.services
Interface CrudWriteService
- All Known Implementing Classes:
AbstractCrudService,AbstractCrudServiceEnvers
public interface CrudWriteService
Generic interface for write operations on entities
- Author:
- eduard
-
Method Summary
Modifier and TypeMethodDescriptionintbatchDelete(Collection<? extends EntityInterface> entities, Integer flushCount) save multiple entities, NOTE that normally only after commit or flush entitymanagers will reflect changes caused by saving all entities, this may cause entitylisteners to fail.<T extends EntityInterface>
Stream<T>batchSave(Collection<T> entities, Integer flushCount) save multiple entities, NOTE that normally only after commit or flush entitymanagers will reflect changes caused by saving all entities, this may cause entitylisteners to fail.<T> Tcreate(T t) voidjakarta.persistence.EntityManager<T> Trefresh(T t) refresh an entity from the database<T extends EntityInterface>
Tsave(T t) create or update depending onEntityInterface.isTransient().<T> Tupdate(T t)
-
Method Details
-
create
<T> T create(T t) -
update
<T> T update(T t) -
save
create or update depending onEntityInterface.isTransient().- Type Parameters:
T-- Parameters:
t-- Returns:
-
delete
-
refresh
<T> T refresh(T t) refresh an entity from the database- Type Parameters:
T-- Parameters:
t-- Returns:
-
batchSave
save multiple entities, NOTE that normally only after commit or flush entitymanagers will reflect changes caused by saving all entities, this may cause entitylisteners to fail. You may need to perform checks on the collection before calling this method. Also note that entitylisteners will execute within the batch transaction, you may need to specifyTransactional.TxTypeon the bean that you use in your listeners, use isolation level 0 (not recommended) or use XA when you need to access resources from your listeners. When flushCount != null flushes and clears the entitymanager every flushCount entities. NOTE that this method executes in one (possibly big) sql transaction! You can useEntityExceptionin for example your listeners to find out in case of failure which enitity caused it.- Parameters:
entities-flushCount- when not null try to optimize (flush/clear) every so many entities- Returns:
- the saved entities
-
batchDelete
save multiple entities, NOTE that normally only after commit or flush entitymanagers will reflect changes caused by saving all entities, this may cause entitylisteners to fail. You may need to perform checks on the collection before calling this method. Also note that entitylisteners will execute within the batch transaction, you may need to specifyTransactional.TxTypeon the bean that you use in your listeners, use isolation level 0 (not recommended) or use XA when you need to access resources from your listeners. When flushCount != null flushes and clears the entitymanager every flushCount entities. NOTE that this method executes in one (possibly big) sql transaction! You can useEntityExceptionin for example your listeners to find out in case of failure which enitity caused it.- Parameters:
entities-flushCount- when not null try to optimize (flush/clear) every so many entities- Returns:
- number of entities deleted
-
getEntityManager
jakarta.persistence.EntityManager getEntityManager()
-