Package org.fryske_akademy.services
Interface CrudWriteService
-
- All Known Implementing Classes:
AbstractCrudService,AbstractCrudServiceEnvers
public interface CrudWriteServiceGeneric interface for write operations on entities- Author:
- eduard
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intbatchDelete(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)voiddelete(EntityInterface t)jakarta.persistence.EntityManagergetEntityManager()<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 Detail
-
create
<T> T create(T t)
-
update
<T> T update(T t)
-
save
<T extends EntityInterface> T save(T t)
create or update depending onEntityInterface.isTransient().- Type Parameters:
T-- Parameters:
t-- Returns:
-
delete
void delete(EntityInterface t)
-
refresh
<T> T refresh(T t)
refresh an entity from the database- Type Parameters:
T-- Parameters:
t-- Returns:
-
batchSave
<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. 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
- See Also:
Util.getBean(Class, Annotation...)
-
batchDelete
int batchDelete(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. 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
- See Also:
Util.getBean(Class, Annotation...)
-
getEntityManager
jakarta.persistence.EntityManager getEntityManager()
-
-