Example usage for org.hibernate LockMode OPTIMISTIC

List of usage examples for org.hibernate LockMode OPTIMISTIC

Introduction

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

Prototype

LockMode OPTIMISTIC

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

Click Source Link

Document

Optimistically assume that transaction will not experience contention for entities.

Usage

From source file:com.github.jmnarloch.hstreams.internal.StatelessSessionDelegateTest.java

License:Apache License

@Test
public void testGetOptional3() throws Exception {

    // given//from  www  .  j  a va  2 s  .  co  m
    final String entityName = "entityName";
    final long id = 1l;
    final LockMode lockMode = LockMode.OPTIMISTIC;

    // when
    instance.getOptional(entityName, id, lockMode);

    // then
    verify().get(entityName, id, lockMode);
}

From source file:com.github.jmnarloch.hstreams.internal.StatelessSessionDelegateTest.java

License:Apache License

@Test
public void testGet1() throws Exception {

    // given/* w  ww .j a va 2  s.  com*/
    final Class<Object> clazz = Object.class;
    final long id = 1l;
    final LockMode lockMode = LockMode.OPTIMISTIC;

    // then
    verifyMethodCall(s -> s.get(clazz, id, lockMode));
}

From source file:com.github.jmnarloch.hstreams.internal.StatelessSessionDelegateTest.java

License:Apache License

@Test
public void testGet3() throws Exception {

    // given//from   ww w . j  a  v a 2s  .com
    final String entityName = "entityName";
    final long id = 1l;
    final LockMode lockMode = LockMode.OPTIMISTIC;

    // then
    verifyMethodCall(s -> s.get(entityName, id, lockMode));
}

From source file:com.github.jmnarloch.hstreams.internal.StatelessSessionDelegateTest.java

License:Apache License

@Test
public void testRefresh2() throws Exception {

    // given/*from  w w  w .  j  a va  2 s .co  m*/
    final Object entity = new Object();
    final LockMode lockMode = LockMode.OPTIMISTIC;

    // then
    verifyMethodCall(s -> s.refresh(entity, lockMode));
}

From source file:com.github.jmnarloch.hstreams.internal.StatelessSessionDelegateTest.java

License:Apache License

@Test
public void testRefresh3() throws Exception {

    // given/*from  w  w w  . jav  a 2  s .co  m*/
    final String entityName = "entityName";
    final Object entity = new Object();
    final LockMode lockMode = LockMode.OPTIMISTIC;

    // then
    verifyMethodCall(s -> s.refresh(entityName, entity, lockMode));
}

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

License:Apache License

/**
 * Borrowed from org.hibernate.ejb.util.LockModeTypeHelper
 * @param lockMode// w  w  w . ja v  a 2 s  .c  om
 * @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);
    }
    }
}