Author: steve.ebersole(a)jboss.com
Date: 2009-05-13 18:48:45 -0400 (Wed, 13 May 2009)
New Revision: 16565
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle10gDialect.java
core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java
Log:
HHH-3912 - Change for HHH-3159 causes InstantiationException
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle10gDialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle10gDialect.java 2009-05-13
22:48:28 UTC (rev 16564)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle10gDialect.java 2009-05-13
22:48:45 UTC (rev 16565)
@@ -24,13 +24,4 @@
public JoinFragment createOuterJoinFragment() {
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";
- }
}
\ No newline at end of file
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java 2009-05-13
22:48:28 UTC (rev 16564)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Oracle8iDialect.java 2009-05-13
22:48:45 UTC (rev 16565)
@@ -359,24 +359,48 @@
}
};
-
- String getOracleTypesClassName() {
- return "oracle.jdbc.driver.OracleTypes";
+
+ public static final String ORACLE_TYPES_CLASS_NAME =
"oracle.jdbc.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.
+ private int oracleCursorTypeSqlType = INIT_ORACLETYPES_CURSOR_VALUE;
+
+ 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;
}
- // not final-static to avoid possible classcast exceptions if using different oracle
drivers.
- int oracletypes_cursor_value = 0;
- public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col)
throws SQLException {
- if(oracletypes_cursor_value==0) {
+ protected int extractOracleCursorTypeValue() {
+ Class oracleTypesClass;
+ try {
+ oracleTypesClass = ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
+ }
+ catch ( ClassNotFoundException cnfe ) {
try {
- Class types = ReflectHelper.classForName(getOracleTypesClassName());
- oracletypes_cursor_value =
types.getField("CURSOR").getInt(types.newInstance());
- } catch (Exception se) {
- throw new HibernateException("Problem while trying to load or access
OracleTypes.CURSOR value",se);
+ oracleTypesClass = ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
}
+ catch ( ClassNotFoundException e ) {
+ 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
- statement.registerOutParameter(col, oracletypes_cursor_value);
+ statement.registerOutParameter( col, getOracleCursorTypeSqlType() );
col++;
return col;
}
Show replies by date