Example usage for org.hibernate LockMode OPTIMISTIC_FORCE_INCREMENT

List of usage examples for org.hibernate LockMode OPTIMISTIC_FORCE_INCREMENT

Introduction

In this page you can find the example usage for org.hibernate LockMode OPTIMISTIC_FORCE_INCREMENT.

Prototype

LockMode OPTIMISTIC_FORCE_INCREMENT

To view the source code for org.hibernate LockMode OPTIMISTIC_FORCE_INCREMENT.

Click Source Link

Document

Optimistically assume that transaction will not experience contention for entities.

Usage

From source file:org.brekka.commons.persistence.dao.hibernate.AbstractIdentifiableEntityHibernateDAO.java

License:Apache License

/**
 * Borrowed from org.hibernate.ejb.util.LockModeTypeHelper
 * @param lockMode//from   w w w.  j a  v a  2 s . c  o  m
 * @return
 */
public static LockMode getLockMode(final LockModeType lockMode) {
    switch (lockMode) {
    case READ:
    case OPTIMISTIC: {
        return LockMode.OPTIMISTIC;
    }
    case OPTIMISTIC_FORCE_INCREMENT:
    case WRITE: {
        return LockMode.OPTIMISTIC_FORCE_INCREMENT;
    }
    case PESSIMISTIC_READ: {
        return LockMode.PESSIMISTIC_READ;
    }
    case PESSIMISTIC_WRITE: {
        return LockMode.PESSIMISTIC_WRITE;
    }
    case PESSIMISTIC_FORCE_INCREMENT: {
        return LockMode.PESSIMISTIC_FORCE_INCREMENT;
    }
    case NONE: {
        return LockMode.NONE;
    }
    default: {
        throw new IllegalStateException("Unknown LockModeType: " + lockMode);
    }
    }
}