Skip to content

Commit

Permalink
MET-6199 add new transaction every time status is saved and clean up …
Browse files Browse the repository at this point in the history
…queries update
  • Loading branch information
jeortizquan committed Nov 4, 2024
1 parent 3d62d4e commit ed89158
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ public interface DatasetDeBiasRepository extends JpaRepository<DatasetDeBiasEnti
@Query("UPDATE DatasetDeBiasEntity dec SET dec.state = ?2 WHERE dec.datasetId.datasetId = ?1")
void updateState(Integer datasetId, String state);

/**
* Delete by dataset id.
*
* @param datasetId the dataset id
*/
@Modifying
@Query("DELETE FROM DatasetDeBiasEntity dec WHERE dec.datasetId.datasetId = ?1")
void deleteByDatasetId(String datasetId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
* The interface Record DeBias detail repository.
Expand All @@ -25,5 +26,8 @@ public interface RecordDeBiasDetailRepository extends JpaRepository<RecordDeBias
* @param datasetId the dataset id
*/
@Modifying
@Query("DELETE FROM RecordDeBiasDetailEntity rdd WHERE EXISTS "
+ "(SELECT 1 FROM RecordDeBiasMainEntity rdm INNER JOIN RecordEntity rec ON rec.id=rdm.recordId.id AND rec.datasetId = ?1 "
+ "WHERE rdd.debiasId.id = rdm.id)")
void deleteByDebiasIdRecordIdDatasetId(String datasetId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
* The interface Record DeBias main repository.
Expand All @@ -26,5 +27,7 @@ public interface RecordDeBiasMainRepository extends JpaRepository<RecordDeBiasMa
* @param datasetId the dataset id
*/
@Modifying
@Query("DELETE FROM RecordDeBiasMainEntity rdm WHERE EXISTS "
+ "(SELECT 1 FROM RecordEntity rec WHERE rec.id=rdm.recordId.id AND rec.datasetId = ?1)")
void deleteByRecordIdDatasetId(String datasetId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
Expand Down Expand Up @@ -89,7 +90,7 @@ public DeBiasProcessServiceImpl(DeBiasClient deBiasClient,
*
* @param recordList the records to process
*/
@Transactional
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void process(List<Record> recordList) {
Objects.requireNonNull(recordList, "List of records is required");
Expand Down

0 comments on commit ed89158

Please sign in to comment.