Commit aac80569 authored by Matija Obreza's avatar Matija Obreza

Inventory group: Clear inventory map before deleting group data

parent 96ec6f45
......@@ -15,6 +15,7 @@
*/
package org.gringlobal.persistence;
import org.gringlobal.model.AccessionInvGroup;
import org.gringlobal.model.AccessionInvGroupMap;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
......@@ -23,4 +24,7 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AccessionInvGroupMapRepository extends JpaRepository<AccessionInvGroupMap, Long>, QuerydslPredicateExecutor<AccessionInvGroupMap> {
/// Delete members of inventory group
int deleteByAccessionInvGroup(AccessionInvGroup entity);
}
......@@ -78,6 +78,16 @@ public class AccessionInvGroupServiceImpl extends FilteredCRUDServiceImpl<Access
return saved;
}
/**
* Override to clear {@link AccessionInvGroup#members}
*/
@Override
@Transactional
public AccessionInvGroup remove(AccessionInvGroup entity) {
accessionInvGroupMapRepository.deleteByAccessionInvGroup(entity);
return super.remove(entity);
}
@Override
public Page<AccessionInvGroup> list(AccessionInvGroupFilter filter, Pageable page) throws SearchException {
return super.list(AccessionInvGroup.class, filter, page);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment