I have a Oracle function which returns sys_refcursor which is
CREATE OR REPLACE FUNCTION SCOTT.getemployees
RETURN SYS_REFCURSOR
AS
o_cursor SYS_REFCURSOR;
BEGIN
OPEN o_cursor FOR
SELECT EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
FROM emp;
RETURN o_cursor;
END;
/
In my Entity class I have declared as
@Entity
@javax.persistence.NamedNativeQuery(name = "getEmp",
query = "{ ? = call getemployees }", resultClass = Employees.class, hints = {
@javax.persistence.QueryHint(name = "org.hibernate.callable", value = "true") })
@Table(name = "EMPLOYEES")
public class Employees {
In DAO I have
@Inject
private SessionFactory sessionFactory;
@Override
public List<Employees> getEmployees() {
List query = new ArrayList<Employees>();
try{
query = sessionFactory.getCurrentSession()
.getNamedQuery("getEmp").list();
}
catch(Exception e){
System.out.println("exception "+e.getMessage());
e.printStackTrace();
}
return query;
}
When I run I am getting exception, what could be the reason for this?
INFO: Hibernate: { ? = call getemployees }
SEVERE: org.hibernate.exception.GenericJDBCException: Missing IN or OUT parameter at index:: 1
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
I have managed to resolve the issue.
Database table columns which are defined as numbers are declared as
intin Entity class.I have changed those to
Integerand problem got resolved.