Skip to content

Commit

Permalink
Integration type locking methods added
Browse files Browse the repository at this point in the history
  • Loading branch information
ibudayeu committed Dec 12, 2023
1 parent 126ee2e commit abf1569
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,37 @@
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.persistence.LockModeType;

/**
* Repository for {@link com.epam.ta.reportportal.entity.integration.IntegrationType} entity
*
* @author Yauheni_Martynau
*/
public interface IntegrationTypeRepository extends ReportPortalRepository<IntegrationType, Long> {

/**
* Find {@link IntegrationType} by id with pessimistic locking to provide synchronization
*
* @param id {@link IntegrationType#getId()}
* @return @return The {@link Optional} of the {@link IntegrationType}
*/
@Query(value = "SELECT * FROM integration_type WHERE id = :id FOR UPDATE", nativeQuery = true)
Optional<IntegrationType> findByIdForUpdate(@Param("id") Long id);

/**
* Retrieve all {@link IntegrationType} with pessimistic locking to provide synchronization
*
* @return The {@link List} of the {@link IntegrationType}
*/
@Lock(LockModeType.PESSIMISTIC_WRITE)
List<IntegrationType> findAllByIdOrderById();

/**
* Retrieve all {@link IntegrationType} by {@link IntegrationType#integrationGroup}
*
Expand Down

0 comments on commit abf1569

Please sign in to comment.