Hi i need to call a stored procedure which returns list of values and take a list of values as input
stored procedure i used is
create or replace PROCEDURE SP_APPL (p_cursor out sys_refcursor,p_columnone varchar2) as em table.columntwo%type; begin em := 0; open p_cursor for SELECT columntwo FROM table WHERE columnone = p_columnone; loop fetch p_cursor into em; exit when p_cursor%notfound; dbms_output.put_line(em); end loop; end; and my hbm.xml is, <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="adh"> <class name="mapperclass" table="table" dynamic-insert="true" > <id name="columntwo" column="ColumnTwo" type="long" unsaved-value="null"> <generator class="assigned"/> </id> <property name="columnone" column="ColumnOne" type="string"/> </class> <sql-query name="SP_APPL" callable="true"> <return class="adh.mapperclass"> <return-property name="columntwo" column="ColumnTwo" /> </return> { call SP_APPL11(?,:column) } </sql-query> </hibernate-mapping>
In mapper class i hav getter and setter methods for all columns
and my java file is ...........
package adh;
import org.hibernate.*; import org.hibernate.cfg.*; import java.util.List;
public class Call { public static void main(String args[]) { Session session = null; SessionFactory factory = null; Transaction t = null;
try { factory = new Configuration().configure().buildSessionFactory(); session = factory.openSession();
Query query = session.getNamedQuery("SP_APPL"); query.setInteger("column",994339714); List list= query.list(); System.out.println("size of the list is " + list.size()); for(int i=0; i<list.size();i++){ System.out.println("list get"+list.get(i));
} session.close(); } catch(Exception e) { e.printStackTrace();
} } }
but i m getting the error as
Hibernate: { call SP_APPL11(?,?) } org.hibernate.QueryTimeoutException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:124) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.doList(Loader.java:2536) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) at org.hibernate.loader.Loader.list(Loader.java:2271) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157) at adh.Call.main(Call.java:25) Caused by: java.sql.SQLException: ORA-01002: fetch out of sequence
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:754) at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210) at oracle.jdbc.driver.T4CStatement.fetch(T4CStatement.java:1035) at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:297) at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:213) at org.hibernate.loader.Loader.doQuery(Loader.java:825) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) at org.hibernate.loader.Loader.doList(Loader.java:2533) ... 7 more Can anyone help me to solve this Thanks in advance for the reply..........
|