Author: steve.ebersole(a)jboss.com
Date: 2009-05-13 18:48:28 -0400 (Wed, 13 May 2009)
New Revision: 16564
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
Log:
HHH-3912 - Change for HHH-3159 causes InstantiationException
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java
===================================================================
---
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java 2009-05-13
22:43:29 UTC (rev 16563)
+++
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java 2009-05-13
22:48:28 UTC (rev 16564)
@@ -47,13 +47,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";
- }
}
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
---
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2009-05-13
22:43:29 UTC (rev 16563)
+++
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2009-05-13
22:48:28 UTC (rev 16564)
@@ -387,24 +387,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;
}