Skip to content
Merged
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 @@ -3,8 +3,10 @@
import java.util.Optional;

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

import in.koreatech.koin.admin.abtest.exception.AccessHistoryNotFoundException;
import in.koreatech.koin.admin.abtest.model.AccessHistory;
Expand All @@ -17,9 +19,13 @@ public interface AccessHistoryRepository extends Repository<AccessHistory, Integ

@Lock(LockModeType.PESSIMISTIC_WRITE)
@QueryHints({@QueryHint(name = "jakarta.persistence.lock.timeout", value = "3000")})
@Query("SELECT a FROM AccessHistory a JOIN FETCH a.device WHERE a.id = :id")
Optional<AccessHistory> findById(Integer id);

Optional<AccessHistory> findByDeviceId(Integer deviceId);
@Lock(LockModeType.PESSIMISTIC_WRITE)
@QueryHints({@QueryHint(name = "jakarta.persistence.lock.timeout", value = "3000")})
@Query("SELECT a FROM AccessHistory a JOIN FETCH a.device WHERE a.device.id = :deviceId")
Optional<AccessHistory> findByDeviceId(@Param("deviceId") Integer deviceId);

default AccessHistory getById(Integer accessHistoryId) {
return findById(accessHistoryId).orElseThrow(() ->
Expand Down
Loading