HHH-3912 - Change for HHH-3159 causes InstantiationException

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16563 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-05-13 22:43:29 +00:00
parent 062e0b5ecd
commit b6b1db702e
2 changed files with 36 additions and 21 deletions

View File

@ -47,13 +47,4 @@ public class Oracle10gDialect extends Oracle9iDialect {
public JoinFragment createOuterJoinFragment() { public JoinFragment createOuterJoinFragment() {
return new ANSIJoinFragment(); return new ANSIJoinFragment();
} }
/*
* The package "oracle.jdbc.driver" was retired in 9.0.1 but works fine up
* through 10g. So as not to mess with 9i, we're changing it in 10g -- we
* may not need an 11g Dialect at all.
*/
String getOracleTypesClassName() {
return "oracle.jdbc.OracleTypes";
}
} }

View File

@ -390,24 +390,48 @@ public class Oracle8iDialect extends Dialect {
} }
}; };
String getOracleTypesClassName() { public static final String ORACLE_TYPES_CLASS_NAME = "oracle.jdbc.OracleTypes";
return "oracle.jdbc.driver.OracleTypes"; public static final String DEPRECATED_ORACLE_TYPES_CLASS_NAME = "oracle.jdbc.driver.OracleTypes";
}
public static final int INIT_ORACLETYPES_CURSOR_VALUE = -99;
// not final-static to avoid possible classcast exceptions if using different oracle drivers. // not final-static to avoid possible classcast exceptions if using different oracle drivers.
int oracletypes_cursor_value = 0; private int oracleCursorTypeSqlType = INIT_ORACLETYPES_CURSOR_VALUE;
public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
if(oracletypes_cursor_value==0) { public int getOracleCursorTypeSqlType() {
if ( oracleCursorTypeSqlType == INIT_ORACLETYPES_CURSOR_VALUE ) {
// todo : is there really any reason to kkeep trying if this fails once?
oracleCursorTypeSqlType = extractOracleCursorTypeValue();
}
return oracleCursorTypeSqlType;
}
protected int extractOracleCursorTypeValue() {
Class oracleTypesClass;
try {
oracleTypesClass = ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
}
catch ( ClassNotFoundException cnfe ) {
try { try {
Class types = ReflectHelper.classForName(getOracleTypesClassName()); oracleTypesClass = ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance()); }
} catch (Exception se) { catch ( ClassNotFoundException e ) {
throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se); throw new HibernateException( "Unable to locate OracleTypes class", e );
} }
} }
try {
return oracleTypesClass.getField( "CURSOR" ).getInt( null );
}
catch ( Exception se ) {
throw new HibernateException( "Unable to access OracleTypes.CURSOR value", se );
}
}
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
// register the type of the out param - an Oracle specific type // register the type of the out param - an Oracle specific type
statement.registerOutParameter(col, oracletypes_cursor_value); statement.registerOutParameter( col, getOracleCursorTypeSqlType() );
col++; col++;
return col; return col;
} }