当前位置: 首页>>代码示例>>Java>>正文


Java LockAcquisitionException类代码示例

本文整理汇总了Java中org.hibernate.exception.LockAcquisitionException的典型用法代码示例。如果您正苦于以下问题:Java LockAcquisitionException类的具体用法?Java LockAcquisitionException怎么用?Java LockAcquisitionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LockAcquisitionException类属于org.hibernate.exception包,在下文中一共展示了LockAcquisitionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSQLExceptionConversionDelegate

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
	return new SQLExceptionConversionDelegate() {
		@Override
		public JDBCException convert(SQLException sqlException, String message, String sql) {
			final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );

			if ( "40P01".equals( sqlState ) ) {
				// DEADLOCK DETECTED
				return new LockAcquisitionException( message, sqlException, sql );
			}

			if ( "55P03".equals( sqlState ) ) {
				// LOCK NOT AVAILABLE
				return new PessimisticLockException( message, sqlException, sql );
			}

			// returning null allows other delegates to operate
			return null;
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:PostgreSQL81Dialect.java

示例2: buildSQLExceptionConversionDelegate

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
	return new SQLExceptionConversionDelegate() {
		@Override
		public JDBCException convert(SQLException sqlException, String message, String sql) {
			final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);
			if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
				return new DataException(message, sqlException, sql);
			} else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
				return new LockAcquisitionException(message, sqlException, sql);
			} else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) {
				return new JDBCConnectionException(message, sqlException, sql);
			}

			// returning null allows other delegates to operate
			return null;
		}
	};
}
 
开发者ID:shilongdai,项目名称:vsDiaryWriter,代码行数:20,代码来源:SQLiteDialect.java

示例3: buildSQLExceptionConverter

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
        return new SQLExceptionConverter() {
                @Override
                public JDBCException convert(SQLException sqlException,
                                String message, String sql) {
                        final String sqlState = JdbcExceptionHelper
                                        .extractSqlState(sqlException);
                        if (sqlState != null) {
                                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                                        return new SQLGrammarException(message, sqlException,
                                                        sql);
                                } else if (DATA_CATEGORIES.contains(sqlState)) {
                                        return new DataException(message, sqlException, sql);
                                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                                        return new LockAcquisitionException(message,
                                                        sqlException, sql);
                                }
                        }
                        return null;
                }
        };
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:GemFireXDDialect.java

示例4: buildSQLExceptionConversionDelegate

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
        return new SQLExceptionConversionDelegate() {
                @Override
                public JDBCException convert(SQLException sqlException,
                                String message, String sql) {
                        final String sqlState = JdbcExceptionHelper
                                        .extractSqlState(sqlException);
                        if (sqlState != null) {
                                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                                        return new SQLGrammarException(message, sqlException,
                                                        sql);
                                } else if (DATA_CATEGORIES.contains(sqlState)) {
                                        return new DataException(message, sqlException, sql);
                                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                                        return new LockAcquisitionException(message,
                                                        sqlException, sql);
                                }
                        }
                        return null;
                }
        };
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:GemFireXDDialect.java

示例5: buildSQLExceptionConverter

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
  return new SQLExceptionConverter() {
    @Override
    public JDBCException convert(SQLException sqlException, String message,
        String sql) {
      final String sqlState = JDBCExceptionHelper
          .extractSqlState(sqlException);
      if (sqlState != null) {
        if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
          return new SQLGrammarException(message, sqlException, sql);
        }
        else if (DATA_CATEGORIES.contains(sqlState)) {
          return new DataException(message, sqlException, sql);
        }
        else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
          return new LockAcquisitionException(message, sqlException, sql);
        }
      }
      return null;
    }
  };
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:GemFireXDDialect.java

示例6: buildSQLExceptionConversionDelegate

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
	return new SQLExceptionConversionDelegate() {
		@Override
		public JDBCException convert(SQLException sqlException, String message, String sql) {
			final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);
			if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
				return new DataException(message, sqlException, sql);
			} else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
				return new LockAcquisitionException(message, sqlException, sql);
			} else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) {
				return new JDBCConnectionException(message, sqlException, sql);
			}
			return null;
		}
	};
}
 
开发者ID:kb2623,项目名称:spletne-seje,代码行数:18,代码来源:SQLiteDialect.java

示例7: buildSQLExceptionConversionDelegate

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
  return new SQLExceptionConversionDelegate() {
    @Override
    public JDBCException convert(SQLException sqlException, String message, String sql) {
      final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);
      if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
        return new DataException(message, sqlException, sql);
      } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
        return new LockAcquisitionException(message, sqlException, sql);
      } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) {
        return new JDBCConnectionException(message, sqlException, sql);
      }

      // returning null allows other delegates to operate
      return null;
    }
  };
}
 
开发者ID:ntenhoeve,项目名称:Introspect-Framework,代码行数:20,代码来源:SQLiteDialect.java

示例8: buildSQLExceptionConverter

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
    return new SQLExceptionConverter() {
        @Override
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final int errorCode = sqlException.getErrorCode();
            if (errorCode == SQLITE_CONSTRAINT) {
                final String constraintName = EXTRACTER.extractConstraintName(sqlException);
                return new ConstraintViolationException(message, sqlException, sql, constraintName);
            } else if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
                return new DataException(message, sqlException, sql);
            } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
                return new LockAcquisitionException(message, sqlException, sql);
            } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) {
                return new JDBCConnectionException(message, sqlException, sql);
            }
            return new GenericJDBCException(message, sqlException, sql);
        }
    };
}
 
开发者ID:sensepost,项目名称:yeti,代码行数:21,代码来源:SQLiteDialect.java

示例9: isLockingException

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
private static boolean isLockingException(final Throwable t, final boolean recurse) {
    if (t instanceof LockingException || t instanceof LockAcquisitionException || t instanceof PessimisticLockException) {
        return true;
    }
    if (t instanceof SQLException) {
        final SQLException e = (SQLException) t;
        return e.getErrorCode() == ER_LOCK_WAIT_TIMEOUT || ST_LOCK.equals(e.getSQLState());
    }
    if (recurse) {
        for (final Throwable thr : ExceptionUtils.getThrowables(t)) {
            if (isLockingException(thr, false)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:18,代码来源:ExceptionHelper.java

示例10: convert

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
    final int errorCode = JdbcExceptionHelper.extractErrorCode(sqlException);
    if (errorCode == SQLITE_CONSTRAINT) {
        final String constraintName = EXTRACTER.extractConstraintName(sqlException);
        return new ConstraintViolationException(message, sqlException, sql, constraintName);
    } else if (errorCode == SQLITE_TOO_BIG || errorCode == SQLITE_MISMATCH) {
        return new DataException(message, sqlException, sql);
    } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
        return new LockAcquisitionException(message, sqlException, sql);
    } else if ((errorCode >= SQLITE_IO_ERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOT_ADB) {
        return new JDBCConnectionException(message, sqlException, sql);
    }
    return new GenericJDBCException(message, sqlException, sql);
}
 
开发者ID:ZsoltFabok,项目名称:sqlite-dialect,代码行数:16,代码来源:SQLiteSQLExceptionConversionDelegate.java

示例11: returnsLockAcquisitionExceptionForSqliteBusy

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Test
public void returnsLockAcquisitionExceptionForSqliteBusy() {
    when(JdbcExceptionHelper.extractErrorCode(sqlException)).thenReturn(5);

    JDBCException exception = conversionDelegate.convert(sqlException, "message", "sql");
    assertTrue(exception instanceof LockAcquisitionException);
    assertEquals("message", exception.getMessage());
    assertEquals("sql", exception.getSQL());
}
 
开发者ID:ZsoltFabok,项目名称:sqlite-dialect,代码行数:10,代码来源:SQLiteSQLExceptionConversionDelegateTest.java

示例12: returnsLockAcquisitionExceptionForSqliteLocked

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Test
public void returnsLockAcquisitionExceptionForSqliteLocked() {
    when(JdbcExceptionHelper.extractErrorCode(sqlException)).thenReturn(6);

    JDBCException exception = conversionDelegate.convert(sqlException, "message", "sql");
    assertTrue(exception instanceof LockAcquisitionException);
    assertEquals("message", exception.getMessage());
    assertEquals("sql", exception.getSQL());
}
 
开发者ID:ZsoltFabok,项目名称:sqlite-dialect,代码行数:10,代码来源:SQLiteSQLExceptionConversionDelegateTest.java

示例13: convert

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
	if ( SQLClientInfoException.class.isInstance( sqlException )
			|| SQLInvalidAuthorizationSpecException.class.isInstance( sqlException )
			|| SQLNonTransientConnectionException.class.isInstance( sqlException )
			|| SQLTransientConnectionException.class.isInstance( sqlException ) ) {
		return new JDBCConnectionException( message, sqlException, sql );
	}
	else if ( DataTruncation.class.isInstance( sqlException ) ||
			SQLDataException.class.isInstance( sqlException ) ) {
		throw new DataException( message, sqlException, sql );
	}
	else if ( SQLIntegrityConstraintViolationException.class.isInstance( sqlException ) ) {
		return new ConstraintViolationException(
				message,
				sqlException,
				sql,
				getConversionContext().getViolatedConstraintNameExtracter().extractConstraintName( sqlException )
		);
	}
	else if ( SQLSyntaxErrorException.class.isInstance( sqlException ) ) {
		return new SQLGrammarException( message, sqlException, sql );
	}
	else if ( SQLTimeoutException.class.isInstance( sqlException ) ) {
		return new QueryTimeoutException( message, sqlException, sql );
	}
	else if ( SQLTransactionRollbackException.class.isInstance( sqlException ) ) {
		// Not 100% sure this is completely accurate.  The JavaDocs for SQLTransactionRollbackException state that
		// it indicates sql states starting with '40' and that those usually indicate that:
		//		<quote>
		//			the current statement was automatically rolled back by the database because of deadlock or
		// 			other transaction serialization failures.
		//		</quote>
		return new LockAcquisitionException( message, sqlException, sql );
	}

	return null; // allow other delegates the chance to look
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:SQLExceptionTypeDelegate.java

示例14: isLockingException

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
private static boolean isLockingException(Throwable throwable) {
	for (Throwable t = throwable; t != null; t = t.getCause()) {
		if (t instanceof StaleStateException || t instanceof LockAcquisitionException) {
			return true;
		}
	}
	return false;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:9,代码来源:JobExecutorThread.java

示例15: lockBatch

import org.hibernate.exception.LockAcquisitionException; //导入依赖的package包/类
/**
 * API to get a batch by applying Hibernate level optimistic locking and to set lock owner ino db.
 * 
 * @param identifier long
 * @param lockOwner {@link ServerRegistry}
 * @throws LockAcquisitionException in case of error
 */
@Transactional
@Override
public void lockBatch(long batchId, ServerRegistry lockOwner) throws LockAcquisitionException {
	BatchInstance batchInstance = batchInstanceDao.getBatch(batchId, LockMode.UPGRADE_NOWAIT);
	if (batchInstance.getLockOwner() == null) {
		batchInstance.setLockOwner(lockOwner);
		batchInstanceDao.saveOrUpdate(batchInstance);
	} else {
		throw new LockAcquisitionException(DataAccessConstant.BATCH_ALREADY_LOCKED, null);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:BatchInstanceServiceImpl.java


注:本文中的org.hibernate.exception.LockAcquisitionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。