使用Hibernate调用存储过程时的ArrayStoreException

时间:2017-05-25 19:34:32

标签: hibernate stored-procedures

使用Hibernate调用存储过程时会出现ArrayStoreException。

java.lang.ArrayStoreException
at java.util.ArrayList.toArray(ArrayList.java:389)
at org.hibernate.util.ArrayHelper.toTypeArray(ArrayHelper.java:99)
at 
org.hibernate.impl.AbstractQueryImpl.typeArray(AbstractQueryImpl.java:855)
at org.hibernate.impl.AbstractQueryImpl.getQueryParameters(AbstractQueryImpl.java:863)
at org.hibernate.impl.SQLQueryImpl.getQueryParameters(SQLQueryImpl.java:217)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)

以下是步骤: -

Java代码调用: -

Query query = hibernatesession.getNamedQuery("getEmployeeById");
query.setParameter(1, 12);
query.list();

SQL查询: -

<sql-query name="getEmployeeById" callable="true">  
    {call sp_GetEmployeeById(?,?)}
</sql-query>

存储过程如下: -

create or replace PROCEDURE sp_GetEmployeeById(employee_result OUT SYS_REFCURSOR, eeId IN NUMBER) 
AS 
BEGIN

  OPEN employee_result FOR

  select * from employee where id = eeId;

END;

有人解决了这个问题吗?

0 个答案:

没有答案