Java Code Examples for org.springframework.dao.PessimisticLockingFailureException

Following code examples demonstrate how to use org.springframework.dao.PessimisticLockingFailureExceptionfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.dao.PessimisticLockingFailureExceptionand various code implementation of this class.

	public Object doConcurrentOperation(ProceedingJoinPoint pjp) throws Throwable {
		PessimisticLockingFailureException lockFailureException;
		do {
			numAttempts++;
			System.out.println("重试次数 : " + numAttempts);
			try {
				return pjp.proceed();
			} catch (PessimisticLockingFailureException ex) {
				lockFailureException = ex;
			}
		} while (numAttempts <= this.maxRetries);
		System.out.println("发生错误 : " + numAttempts);
		throw lockFailureException;
	} 


    public void save(int x){
        System.out.println("Throw Exception : " + x);
        throw new PessimisticLockingFailureException("");
    } 

Advertisement
Javadoc
Exception thrown on a pessimistic locking violation. Thrown by Spring's SQLException translation mec

hanism if a corresponding database error is encountered.

Serves as superclass for more specific exceptions, like CannotAcquireLockException and DeadlockLoserDataAccessException. @author Thomas Risberg @since 1.2 @see CannotAcquireLockException @see DeadlockLoserDataAccessException @see OptimisticLockingFailureException

Read More
Advertisement