org.springframework.data.jpa.repository.Lock Java Examples
The following examples show how to use
org.springframework.data.jpa.repository.Lock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationRepository.java From steady with Apache License 2.0 | 5 votes |
/** * Finds the applications whose dependencies include constructs from the given list. * Note: the outer select a was added because the lock does not allow the use of "distinct" and we want to avoid to update the same application multiple times in the subsequent update query * * @param listOfConstructs list of {@link ConstructId} * @return list of {@link Application} */ @Lock(LockModeType.PESSIMISTIC_WRITE) @Transactional @Query("select a from Application a where a in" + "( SELECT distinct d.app FROM Dependency d " + " JOIN " + " d.lib l" + " JOIN " + " l.constructs lc " + " WHERE lc IN :listOfConstructs " + " AND (NOT lc.type='PACK' " // Java + Python exception + " OR NOT EXISTS (SELECT 1 FROM ConstructChange cc1 JOIN cc1.constructId c1 WHERE c1 IN :listOfConstructs AND NOT c1.type='PACK' AND NOT c1.qname LIKE '%test%' AND NOT c1.qname LIKE '%Test%' and NOT cc1.constructChangeType='ADD') ) " + " AND NOT (lc.type='MODU' AND (lc.qname='setup' OR lc.qname='tests' OR lc.qname='test.__init__')) )" // Python-specific exception: setup.py is virtually everywhere, considering it would bring far too many FPs. Similarly tests.py originates such a generic module that would bring up too many FPs ) List<Application> findAppsByCC(@Param("listOfConstructs") List<ConstructId> listOfConstructs);
Example #2
Source File: ApplicationRepository.java From steady with Apache License 2.0 | 5 votes |
/** * Finds the applications whose dependencies include {@link LibraryId}s from the given list. * Note: the outer select a was added because the lock does not allow the use of "distinct" and we want to avoid to update the same application multiple times in the subsequent update query * * @return list of {@link Application} * @param affLibId a {@link com.sap.psr.vulas.backend.model.LibraryId} object. */ @Lock(LockModeType.PESSIMISTIC_WRITE) @Transactional @Query("select a from Application a where a in" + "( SELECT distinct d.app FROM Dependency d " + " JOIN " + " d.lib l" + " JOIN " + " l.libraryId dep_libid" + " WHERE dep_libid = :affLibId )" ) List<Application> findAppsByAffLib(@Param("affLibId") LibraryId affLibId);
Example #3
Source File: CommandEntityRepository.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@Lock(LockModeType.OPTIMISTIC) @Query(value = "SELECT * FROM Command AS c " + "WHERE c.eventId IN (" + " SELECT MAX(c1.eventId) FROM Command AS c1 " + " INNER JOIN Command AS c2 on c1.globalTxId = c2.globalTxId" + " WHERE c1.status = 'NEW' " + " GROUP BY c1.globalTxId " + " HAVING MAX( CASE c2.status WHEN 'PENDING' THEN 1 ELSE 0 END ) = 0) " + "ORDER BY c.eventId ASC LIMIT 1", nativeQuery = true) List<Command> findFirstGroupByGlobalTxIdWithoutPendingOrderByIdDesc();
Example #4
Source File: CommandEntityRepository.java From txle with Apache License 2.0 | 5 votes |
@Lock(LockModeType.OPTIMISTIC) @Query(value = "SELECT * FROM Command AS c " + "WHERE c.eventId IN (" + " SELECT MAX(c1.eventId) FROM Command AS c1 " + " INNER JOIN Command AS c2 on c1.globalTxId = c2.globalTxId" + " WHERE c1.status = 'NEW' " + " GROUP BY c1.globalTxId " + " HAVING MAX( CASE c2.status WHEN 'PENDING' THEN 1 ELSE 0 END ) = 0) " // + "ORDER BY c.eventId ASC LIMIT 1", nativeQuery = true)// 'LIMIT 1' made an effect on performance, and Compensation Command is always executed one by one. So, we canceled 'LIMIT 1'. + "ORDER BY c.eventId ASC", nativeQuery = true) // 查询某全局事务没有PENDING状态且为NEW状态的Command List<Command> findFirstGroupByGlobalTxIdWithoutPendingOrderByIdDesc();
Example #5
Source File: TransactionDao.java From payment with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) @Query("SELECT m FROM #{#entityName} m WHERE m.transactionNo=:orderNo") List<TransactionPO> findByOrderNoOnLock(@Param("orderNo") String orderNo);
Example #6
Source File: BookRatingRepository.java From spring-data-examples with Apache License 2.0 | 4 votes |
@Lock(PESSIMISTIC_READ) @Query("select br from BookRating br where br.book.isbn = :isbn") BookRating findByBookIsbnPessimisticReadLock(String isbn);
Example #7
Source File: BookRatingRepository.java From spring-data-examples with Apache License 2.0 | 4 votes |
@Lock(PESSIMISTIC_WRITE) @Query("select br from BookRating br where br.book.isbn = :isbn") BookRating findByBookIsbnPessimisticWriteLock(String isbn);
Example #8
Source File: BookRatingRepository.java From spring-data-examples with Apache License 2.0 | 4 votes |
@Lock(OPTIMISTIC_FORCE_INCREMENT) @Query("select br from BookRating br where br.book.isbn = :isbn") BookRating findByBookIsbnOptimisticForceIncrementLock(String isbn);
Example #9
Source File: BookRatingRepository.java From spring-data-examples with Apache License 2.0 | 4 votes |
@Lock(OPTIMISTIC) @Query("select br from BookRating br where br.book.isbn = :isbn") BookRating findByBookIsbnOptimisticLock(String isbn);
Example #10
Source File: PersonRepository.java From tutorials with MIT License | 4 votes |
@Lock(LockModeType.NONE) @Query("SELECT COUNT(*) FROM Person p") long getPersonCount();
Example #11
Source File: UserInvitationRepository.java From wallride with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) UserInvitation findOneForUpdateByToken(String token);
Example #12
Source File: UserRepository.java From wallride with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) User findOneForUpdateById(Long id);
Example #13
Source File: TagRepository.java From wallride with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) Tag findOneForUpdateByNameAndLanguage(String name, String language);
Example #14
Source File: TagRepository.java From wallride with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) Tag findOneForUpdateByIdAndLanguage(Long id, String language);
Example #15
Source File: BlogRepository.java From wallride with Apache License 2.0 | 4 votes |
@EntityGraph(value = Blog.DEEP_GRAPH_NAME, type = EntityGraph.EntityGraphType.FETCH) @Lock(LockModeType.PESSIMISTIC_WRITE) Blog findOneForUpdateById(Long id);
Example #16
Source File: MediaRepository.java From wallride with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) Media findOneForUpdateById(String id);
Example #17
Source File: CommentRepository.java From wallride with Apache License 2.0 | 4 votes |
@EntityGraph(value = Comment.DEEP_GRAPH_NAME, type = EntityGraph.EntityGraphType.FETCH) @Lock(LockModeType.PESSIMISTIC_WRITE) Comment findOneForUpdateById(Long id);
Example #18
Source File: TransactionDao.java From payment with Apache License 2.0 | 4 votes |
@Lock(LockModeType.PESSIMISTIC_WRITE) @Query("SELECT m FROM #{#entityName} m WHERE m.id=:transactionId") TransactionPO findOneOnLock(@Param("transactionId") Long transactionId);
Example #19
Source File: TxTimeoutEntityRepository.java From servicecomb-pack with Apache License 2.0 | 4 votes |
@Lock(LockModeType.OPTIMISTIC) @Query("SELECT t FROM TxTimeout AS t " + "WHERE t.status = 'NEW' " + " AND t.expiryTime < CURRENT_TIMESTAMP " + "ORDER BY t.expiryTime ASC") List<TxTimeout> findFirstTimeoutTxOrderByExpireTimeAsc(Pageable pageable);
Example #20
Source File: TxTimeoutEntityRepository.java From txle with Apache License 2.0 | 4 votes |
@Lock(LockModeType.OPTIMISTIC) @Query(value = "SELECT * FROM TxTimeout AS t " + "WHERE t.status = 'NEW' " + " AND t.expiryTime < ?1 " + "ORDER BY t.expiryTime ASC" + EventScanner.SCANNER_SQL, nativeQuery = true) List<TxTimeout> findFirstTimeoutTxOrderByExpireTimeAsc(/*Pageable pageable, */Date currentDateTime);
Example #21
Source File: TxTimeoutEntityRepository.java From txle with Apache License 2.0 | 4 votes |
@Lock(LockModeType.OPTIMISTIC) @Query("SELECT t FROM TxTimeout AS t " + "WHERE t.status = 'NEW' " + " AND t.expiryTime < CURRENT_TIMESTAMP " + "ORDER BY t.expiryTime ASC") List<TxTimeout> findFirstTimeoutTxOrderByExpireTimeAsc(Pageable pageable);
Example #22
Source File: JpaRepositoryCustomisations.java From rest-example with Apache License 2.0 | 2 votes |
/** * Persists the supplied entity. * If the entity has an id and previously has been persisted, it will be merged * to the persistence context otherwise it will be inserted into the * persistence context. * * @param inEntity Entity to persist. * @return Persisted entity. */ @Lock(LockModeType.PESSIMISTIC_WRITE) T persist(T inEntity);
Example #23
Source File: AppRepository.java From heimdall with Apache License 2.0 | 2 votes |
/** * Finds a List of {@link Plan} associated with a App. * * @param appId The App Id * @return The list of Plan */ @Lock(LockModeType.NONE) @Query("select p from App a join a.plans p where a.id = :appId") List<Plan> findPlansByApp(@Param("appId") Long appId);
Example #24
Source File: AppRepository.java From heimdall with Apache License 2.0 | 2 votes |
/** * Finds a App by its name. * * @param name The App name * @return The App found */ @Lock(LockModeType.NONE) App findByName(String name);
Example #25
Source File: AppRepository.java From heimdall with Apache License 2.0 | 2 votes |
/** * Finds a App by its client Id. * * @param clientId The client id * @return The App found */ @Lock(LockModeType.NONE) @Cacheable(ConstantsCache.APPS_CLIENT_ID) App findByClientId(String clientId);
Example #26
Source File: AppRepository.java From heimdall with Apache License 2.0 | 2 votes |
/** * Finds a active App by its client Id. * * @param clientId The client id * @return The App found */ @Lock(LockModeType.NONE) @Cacheable(ConstantsCache.APPS_ACTIVE_CACHE) @Query("select a from App a join a.plans p where a.clientId = :clientId and a.status = 'ACTIVE' and p.status = 'ACTIVE' ") App findAppActive(@Param("clientId") String clientId);