Hibernate version:
3.0
In our application we are using Oracle database and "select" queries was encapsulated in store procedures in the following way:
{ <cursor> = call some_store_procedure ( <feedback_code>, <return_code>, <param1>, ..., <paramN>) }
where:
- store procedure open cursor with result set and return it in 1st output parameter (cursor)
- store procedure also return into 2nd and 3rd output parameters some codes (it doesn't matter, because if need we can to remove these output parameters, but not 1st)
So, for me need the following when I call Query.list method I have to receive list of objects of some specific class.
How I understand I should to implement my own loader for this (correct me, if no). But I have some questions about this:
1. In Loader.prepareQueryStatement we have the following code:
Quote:
CallableStatement st = session.getBatcher()
.prepareQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
how can I override this behaviour and call
prepareCallableStatement method of batcher, not prepareQueryStatement?
2. Where I should put this code:
st.registerOutParameter( 1, OracleTypes.CURSOR );
st.registerOutParameter( 2, OracleTypes.VARCHAR );
st.registerOutParameter( 3, OracleTypes.INTEGER );
?
3. Dialect class has method bindLimitParametersFirst... Should I to create my own dialect and return
3 as offset for input parameters (because 1st,2nd and 3rd parameters are always output parameters) or it can be done in some more properly way?
4. Batcher has interface getResultSet. How I understan I have to implement my own Batcher (that extends, for example BatchingBatcher) and override this method from default behaviour:
Quote:
public ResultSet getResultSet(PreparedStatement ps) throws SQLException {
ResultSet rs = ps.executeQuery();
resultSetsToClose.add(rs);
logOpenResults();
return rs;
}
to something like this:
Quote:
public ResultSet getResultSet(PreparedStatement ps) throws SQLException {
Connection connection = ps.getConnection();
boolean oldAutoCommit = connection.getAutoCommit();
connection.setAutoCommit(false);
try{
ps.execute();
}finally{
if( oldAutoCommit ) {
connection.setAutoCommit(true);
}
}
ResultSet rs = (ResultSet) ((CallableStatement)ps).getObject(1);
resultSetsToClose.add(rs);
logOpenResults();
return rs;
}
but where I can to configure that hibernate should yo use my own batcher for this specific query?
5. Also currently, after my previous hardcoded modificiations, Loader.getRowFromResultSet method return only emtpy Object array because getEntityPersisters method return empty array. If this possible, can you advise how to properly initilize entity persisters?
Thanks,
Maxim