Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration type locking methods added #960

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading