Example usage for javax.persistence TypedQuery setLockMode

List of usage examples for javax.persistence TypedQuery setLockMode

Introduction

In this page you can find the example usage for javax.persistence TypedQuery setLockMode.

Prototype

TypedQuery<X> setLockMode(LockModeType lockMode);

Source Link

Document

Set the lock mode type to be used for the query execution.

Usage

From source file:org.springframework.data.jpa.repository.support.SimpleJpaRepository.java

private TypedQuery<T> applyRepositoryMethodMetadata(TypedQuery<T> query) {

    if (crudMethodMetadata == null) {
        return query;
    }/*from ww  w  .java 2  s  .  co m*/

    LockModeType type = crudMethodMetadata.getLockModeType();
    TypedQuery<T> toReturn = type == null ? query : query.setLockMode(type);

    for (Entry<String, Object> hint : crudMethodMetadata.getQueryHints().entrySet()) {
        query.setHint(hint.getKey(), hint.getValue());
    }

    return toReturn;
}