Java Code Examples for javax.persistence.LockModeType#NONE

The following examples show how to use javax.persistence.LockModeType#NONE . 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: LockModeConverter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Convert from the Hibernate specific LockMode to the JPA defined LockModeType.
 *
 * @param lockMode The Hibernate LockMode.
 *
 * @return The JPA LockModeType
 */
public static LockModeType convertToLockModeType(LockMode lockMode) {
	if ( lockMode == LockMode.NONE ) {
		return LockModeType.NONE;
	}
	else if ( lockMode == LockMode.OPTIMISTIC || lockMode == LockMode.READ ) {
		return LockModeType.OPTIMISTIC;
	}
	else if ( lockMode == LockMode.OPTIMISTIC_FORCE_INCREMENT || lockMode == LockMode.WRITE ) {
		return LockModeType.OPTIMISTIC_FORCE_INCREMENT;
	}
	else if ( lockMode == LockMode.PESSIMISTIC_READ ) {
		return LockModeType.PESSIMISTIC_READ;
	}
	else if ( lockMode == LockMode.PESSIMISTIC_WRITE
			|| lockMode == LockMode.UPGRADE
			|| lockMode == LockMode.UPGRADE_NOWAIT
			|| lockMode == LockMode.UPGRADE_SKIPLOCKED) {
		return LockModeType.PESSIMISTIC_WRITE;
	}
	else if ( lockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT
			|| lockMode == LockMode.FORCE ) {
		return LockModeType.PESSIMISTIC_FORCE_INCREMENT;
	}
	throw new AssertionFailure( "unhandled lock mode " + lockMode );
}
 
Example 2
Source File: CdiQueryInvocationContext.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private LockModeType extractLockMode()
{
    org.apache.deltaspike.data.api.Query query = getRepositoryMethodMetadata().getQuery();
    if (query != null && query.lock() != LockModeType.NONE)
    {
        return query.lock();
    }

    return null;
}
 
Example 3
Source File: PersonRepository.java    From tutorials with MIT License 4 votes vote down vote up
@Lock(LockModeType.NONE)
@Query("SELECT COUNT(*) FROM Person p")
long getPersonCount();
 
Example 4
Source File: AppRepository.java    From heimdall with Apache License 2.0 2 votes vote down vote up
/**
* 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);
 
Example 5
Source File: AppRepository.java    From heimdall with Apache License 2.0 2 votes vote down vote up
/**
 * 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 6
Source File: AppRepository.java    From heimdall with Apache License 2.0 2 votes vote down vote up
/**
 * Finds a App by its name.
 * 
 * @param  name			The App name
 * @return				The App found
 */
    @Lock(LockModeType.NONE)
App findByName(String name);
 
Example 7
Source File: AppRepository.java    From heimdall with Apache License 2.0 2 votes vote down vote up
/**
 * 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);