Interface SessionInfoRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<SessionInfo,,String> org.springframework.data.jpa.repository.JpaRepository<SessionInfo,,String> org.springframework.data.repository.ListCrudRepository<SessionInfo,,String> org.springframework.data.repository.ListPagingAndSortingRepository<SessionInfo,,String> org.springframework.data.repository.PagingAndSortingRepository<SessionInfo,,String> org.springframework.data.repository.query.QueryByExampleExecutor<SessionInfo>,org.springframework.data.repository.Repository<SessionInfo,String>
public interface SessionInfoRepository
extends org.springframework.data.jpa.repository.JpaRepository<SessionInfo,String>
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteAllRelatedSessionsAndCheckpoints(String sessionId) voiddeleteOldRecordsByInterval(String olderThan) Remove old records for scheduled cleanup taskfindAllByChainIdAndExecutionStatus(String chainId, ExecutionStatus status) findOriginalSessionInfo(String sessionId) Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findAllByChainIdAndExecutionStatus
-
deleteAllRelatedSessionsAndCheckpoints
@Modifying @Query(nativeQuery=true, value="WITH RECURSIVE to_root_node (id, original_session_id) AS ( SELECT s1.id, s1.original_session_id FROM engine.sessions_info s1 WHERE s1.id = :sessionId UNION ALL SELECT s2.id, s2.original_session_id FROM engine.sessions_info s2 JOIN to_root_node rn ON rn.original_session_id = s2.id )DELETE FROM engine.sessions_info WHERE id = (SELECT id FROM to_root_node WHERE original_session_id IS NULL LIMIT 1);") void deleteAllRelatedSessionsAndCheckpoints(String sessionId) -
findOriginalSessionInfo
@Query(nativeQuery=true, value="with recursive session_info as (\n select s1.*\n from engine.sessions_info s1\n where s1.id = :sessionId\n union all\n select s2.*\n from engine.sessions_info s2\n join session_info si on s2.id = si.original_session_id\n)\nselect * from session_info i\n where i.id != :sessionId and i.original_session_id is null\n limit 1;\n") Optional<SessionInfo> findOriginalSessionInfo(String sessionId) -
deleteOldRecordsByInterval
@Modifying @Query(nativeQuery=true, value="DELETE FROM engine.sessions_info s1 WHERE s1.started < now() - ( :olderThan )\\:\\:interval AND s1.original_session_id IS NULL") void deleteOldRecordsByInterval(String olderThan) Remove old records for scheduled cleanup task- Parameters:
olderThan- interval string, for example: '1 hour', '7 days', '2 years 3 month'
-