[英]Hibernate: convert cursor returned from stored procedure to List
I have implemented a code for calling stored procedure from hibernate. 我已经实现了用于从休眠状态调用存储过程的代码。 The sp returns a cursor, how do I get the result in List.
sp返回一个游标,如何在List中得到结果。
Below is my code for calling the sp. 下面是我调用sp的代码。 How to I create a list from callstm.getObject(1);
我如何从callstm.getObject(1)创建列表;
I'm using Oracle. 我正在使用Oracle。
Transaction tx = sessionFactory.getCurrentSession().beginTransaction();
Session session = sessionFactory.getCurrentSession();
session.doReturningWork(new ReturningWork<Object>() {
@SuppressWarnings( "unchecked" )
@Override
public Object execute( Connection aConnection ) throws SQLException
{
CallableStatement callstm = null;
try
{
String functionCall = "{call PORTAL_PKG._pp_member_login(?, ?, ?, ? )}";
callstm = aConnection.prepareCall( functionCall );
callstm.registerOutParameter( 1, OracleTypes.CURSOR );
callstm.setString( 2, "Partner" );
callstm.setString( 3, "Member" );
callstm.setString( 4, "test@123" );
callstm.execute();
callstm.getObject(1);
}
finally
{
callstm.close();
}
}
});
Thanks in advance. 提前致谢。
I think this should work. 我认为这应该有效。
...
callstm.execute();
ResultSet rset = (ResultSet)callstm.getObject(1);
while (rset.next()){
System.out.println(rset.getString(columnIndex));
}
// Close all the resources
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.