Example usage for javax.persistence OptimisticLockException getMessage

List of usage examples for javax.persistence OptimisticLockException getMessage

Introduction

In this page you can find the example usage for javax.persistence OptimisticLockException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:se.nrm.dina.data.jpa.impl.DinaDaoImpl.java

@Override
public T merge(T entity) {

    logger.info("merge: {}", entity);

    T tmp = entity;//from ww  w.j  a  v a  2s.  co  m
    try {
        tmp = entityManager.merge(entity);
        entityManager.flush(); // this one used for throwing OptimisticLockException if method called with web service
        //            entityManager.clear();
    } catch (OptimisticLockException e) {
        logger.warn(e.getMessage());
    } catch (ConstraintViolationException e) {
        logger.warn(e.getMessage());
        throw new DinaException(handleConstraintViolation(e));
    } catch (Exception e) {
        logger.warn(e.getMessage());
    }
    return tmp;
}