Permalink
Browse files

HHH-7298 regression, org.hibernate.ejb.test.lock.LockTest

  • Loading branch information...
stliu committed May 30, 2012
1 parent 2910335 commit 2b213dabc3077b9e38be232bf65e11472365243d
@@ -28,13 +28,17 @@
import java.sql.SQLException;
import java.sql.Types;
+import org.hibernate.JDBCException;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.LockTimeoutException;
+import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
+import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
@@ -427,4 +431,21 @@ public boolean supportsTupleDistinctCounts() {
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
return sqlCode == Types.BOOLEAN ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
+
+ @Override
+ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
+ return new SQLExceptionConversionDelegate() {
+ @Override
+ public JDBCException convert(SQLException sqlException, String message, String sql) {
+ final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );
+ final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
+
+ if( -952 == errorCode && "57014".equals( sqlState )){
+ throw new LockTimeoutException( message, sqlException, sql );
+ }
+ return null;
+ }
+ };
+ }
+
}
@@ -32,6 +32,7 @@
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.LockTimeoutException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.internal.util.JdbcExceptionHelper;
@@ -292,17 +293,15 @@ public Boolean performTemporaryTableDDLInIsolation() {
}
public String getCastTypeName(int code) {
- if ( code==Types.INTEGER ) {
- return "signed";
- }
- else if ( code==Types.VARCHAR ) {
- return "char";
- }
- else if ( code==Types.VARBINARY ) {
- return "binary";
- }
- else {
- return super.getCastTypeName( code );
+ switch ( code ){
+ case Types.INTEGER:
+ return "signed";
+ case Types.VARCHAR:
+ return "char";
+ case Types.VARBINARY:
+ return "binary";
+ default:
+ return super.getCastTypeName( code );
}
}
@@ -389,6 +388,10 @@ public JDBCException convert(SQLException sqlException, String message, String s
return new LockTimeoutException( message, sqlException, sql );
}
+ if ( "40001".equals( sqlState ) ) {
+ return new LockAcquisitionException( message, sqlException, sql );
+ }
+
return null;
}
};
@@ -65,11 +65,8 @@ public Oracle8iDialect() {
registerNumericTypeMappings();
registerDateTimeTypeMappings();
registerLargeObjectTypeMappings();
-
registerReverseHibernateTypeMappings();
-
registerFunctions();
-
registerDefaultProperties();
}
@@ -221,13 +218,15 @@ protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
*
* @return The orqacle join fragment
*/
+ @Override
public JoinFragment createOuterJoinFragment() {
return new OracleJoinFragment();
}
/**
* {@inheritDoc}
*/
+ @Override
public String getCrossJoinSeparator() {
return ", ";
}
@@ -238,10 +237,11 @@ public String getCrossJoinSeparator() {
*
* @return The oracle CASE -> DECODE fragment
*/
+ @Override
public CaseFragment createCaseFragment() {
return new DecodeCaseFragment();
}
-
+ @Override
public String getLimitString(String sql, boolean hasOffset) {
sql = sql.trim();
boolean isForUpdate = false;
@@ -282,7 +282,7 @@ public String getLimitString(String sql, boolean hasOffset) {
public String getBasicSelectClauseNullString(int sqlType) {
return super.getSelectClauseNullString( sqlType );
}
-
+ @Override
public String getSelectClauseNullString(int sqlType) {
switch(sqlType) {
case Types.VARCHAR:
@@ -296,82 +296,82 @@ public String getSelectClauseNullString(int sqlType) {
return "to_number(null)";
}
}
-
+ @Override
public String getCurrentTimestampSelectString() {
return "select sysdate from dual";
}
-
+ @Override
public String getCurrentTimestampSQLFunctionName() {
return "sysdate";
}
// features which remain constant across 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~
-
+ @Override
public String getAddColumnString() {
return "add";
}
-
+ @Override
public String getSequenceNextValString(String sequenceName) {
return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
}
-
+ @Override
public String getSelectSequenceNextValString(String sequenceName) {
return sequenceName + ".nextval";
}
-
+ @Override
public String getCreateSequenceString(String sequenceName) {
return "create sequence " + sequenceName; //starts with 1, implicitly
}
-
+ @Override
public String getDropSequenceString(String sequenceName) {
return "drop sequence " + sequenceName;
}
-
+ @Override
public String getCascadeConstraintsString() {
return " cascade constraints";
}
-
+ @Override
public boolean dropConstraints() {
return false;
}
-
+ @Override
public String getForUpdateNowaitString() {
return " for update nowait";
}
-
+ @Override
public boolean supportsSequences() {
return true;
}
-
+ @Override
public boolean supportsPooledSequences() {
return true;
}
-
+ @Override
public boolean supportsLimit() {
return true;
}
-
+ @Override
public String getForUpdateString(String aliases) {
return getForUpdateString() + " of " + aliases;
}
-
+ @Override
public String getForUpdateNowaitString(String aliases) {
return getForUpdateString() + " of " + aliases + " nowait";
}
-
+ @Override
public boolean bindLimitParametersInReverseOrder() {
return true;
}
-
+ @Override
public boolean useMaxForLimit() {
return true;
}
-
+ @Override
public boolean forUpdateOfColumns() {
return true;
}
-
+ @Override
public String getQuerySequencesString() {
return " select sequence_name from all_sequences"
+ " union"
@@ -380,11 +380,11 @@ public String getQuerySequencesString() {
+ " where asq.sequence_name = us.table_name"
+ " and asq.sequence_owner = us.table_owner";
}
-
+ @Override
public String getSelectGUIDString() {
return "select rawtohex(sys_guid()) from dual";
}
-
+ @Override
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
}
@@ -501,63 +501,63 @@ protected int extractOracleCursorTypeValue() {
throw new HibernateException( "Unable to access OracleTypes.CURSOR value", se );
}
}
-
+ @Override
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
// register the type of the out param - an Oracle specific type
statement.registerOutParameter( col, getOracleCursorTypeSqlType() );
col++;
return col;
}
-
+ @Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
ps.execute();
return ( ResultSet ) ps.getObject( 1 );
}
-
+ @Override
public boolean supportsUnionAll() {
return true;
}
-
+ @Override
public boolean supportsCommentOn() {
return true;
}
-
+ @Override
public boolean supportsTemporaryTables() {
return true;
}
-
+ @Override
public String generateTemporaryTableName(String baseTableName) {
String name = super.generateTemporaryTableName(baseTableName);
return name.length() > 30 ? name.substring( 1, 30 ) : name;
}
-
+ @Override
public String getCreateTemporaryTableString() {
return "create global temporary table";
}
-
+ @Override
public String getCreateTemporaryTablePostfix() {
return "on commit delete rows";
}
-
+ @Override
public boolean dropTemporaryTableAfterUse() {
return false;
}
-
+ @Override
public boolean supportsCurrentTimestampSelection() {
return true;
}
-
+ @Override
public boolean isCurrentTimestampSelectStringCallable() {
return false;
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+ @Override
public boolean supportsEmptyInList() {
return false;
}
-
+ @Override
public boolean supportsExistsInSelect() {
return false;
}
Oops, something went wrong.

0 comments on commit 2b213da

Please sign in to comment.