hi all,
Can anyone tell me how to call a function from Hibernate. I
tried with below code but it gives an exception.
SessionFactory sessionFactory =
*new* Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
Query query = session.getNamedQuery("flight_details");
List result = query.list();
*displayObjectList*(result);
*
org.hibernate.exception.GenericJDBCException*: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(*
SQLStateConverter.java:103*)
at org.hibernate.exception.SQLStateConverter.convert(*
SQLStateConverter.java:91*)
at org.hibernate.exception.JDBCExceptionHelper.convert(*
JDBCExceptionHelper.java:43*)
Caused by:
*java.sql.SQLException*: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(*
DatabaseError.java:112*)
at oracle.jdbc.driver.DatabaseError.throwSqlException(*
DatabaseError.java:146*)
at oracle.jdbc.driver.DatabaseError.throwSqlException(*
DatabaseError.java:208*)
*FYI:*
*My Backend function is:*
CREATE OR REPLACE
FUNCTION flight_details RETURN SYS_REFCURSOR
AS
type st_cursor is ref cursor;
c1 st_cursor;
r_c1 flight%rowtype;
BEGIN
OPEN c1 FOR
SELECT * FROM FLIGHT WHERE FCLASS='F';
return c1;
END;
--
Bhavani.S