-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Map cursor from store procedures on entity
PostPosted: Fri Jan 28, 2005 9:34 am 
Newbie

Joined: Fri Jan 28, 2005 7:59 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
we are working on providing stored procedure querying support.

we will probably only start out with having support for returning a resultset.

You can find latest discussions on this by searching and looking on the hbierate devel list - their you will find the info you can get (or at least a plan for how to do it in hibernate 3)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.