I am attempting to use JPA 2.1 and Hibernate 4.3.5 with Java 7 with stored procedures. I am using Oracle10gDialect and Oracle jdbc drivers for 11g. There seems to be at least 2 problems with stored procedure support with Oracle. Since I am using Java 7 and there are no Oracle drivers yet that support JDBC 4.2, stored procedures rely on the specific oracle dialect to set the parameters properly. Oracle uses Ref Cursor support to get results and that seems to be where the problem is.
1) There is no support for using named parameters with stored procedures. The Oracle 8i dialect doesn't override:
public int registerResultSetOutParameter(CallableStatement statement, String name) throws SQLException
so when this method is called an exception is thrown by the top level Dialect class that says it's not supported. I attempted to add this method to a custom dialect and it gave another exception saying that Ordinal binding and Named binding can not be combined.
2) The oracle 8i dialect does not override:
public ResultSet getResultSet(CallableStatement statement, int position) throws SQLException
which causes stored procedures with positional parameters to also fail. Note that this method is in fact implemented in PostgresSQL81Dialect. When I tied a custom dialect that extended Oracle10gDialect and used the implementation from Postgres and this fixes the Oracle issue.
|