Changed transaction handling for importing entities.

deploy_packages_to_gitea
Jens Pelzetter 2023-01-26 19:17:20 +01:00
parent 4b6bd259eb
commit 677a187618
1 changed files with 4 additions and 2 deletions

View File

@ -152,7 +152,7 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
* @see #updateExistingEntity(org.libreccm.imexport.Exportable, * @see #updateExistingEntity(org.libreccm.imexport.Exportable,
* org.libreccm.imexport.Exportable) * org.libreccm.imexport.Exportable)
*/ */
@Transactional(Transactional.TxType.REQUIRES_NEW) @Transactional(Transactional.TxType.REQUIRED)
public T importEntity(final String data) throws ImportExpection { public T importEntity(final String data) throws ImportExpection {
try { try {
final T importedEntity = objectMapper.readValue(data, final T importedEntity = objectMapper.readValue(data,
@ -164,10 +164,12 @@ public abstract class AbstractEntityImExporter<T extends Exportable> {
final T existingEntity = existingEntityResult.get(); final T existingEntity = existingEntityResult.get();
updateExistingEntity(existingEntity, importedEntity); updateExistingEntity(existingEntity, importedEntity);
entityManager.flush();
return existingEntity; return existingEntity;
} else { } else {
saveImportedEntity(importedEntity); saveImportedEntity(importedEntity);
entityManager.flush();
return importedEntity; return importedEntity;
} }
} catch (IOException ex) { } catch (IOException ex) {