gpt4 book ai didi

hibernate - 严重:org.hibernate.exception.GenericJDBCException:索引处缺少 IN 或 OUT 参数::1

转载 作者:行者123 更新时间:2023-12-04 05:19:36 25 4
gpt4 key购买 nike

我有一个 Oracle 函数,它返回 sys_refcursor,它是

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;
/

在我的实体类中,我声明为
@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 {

在 DAO 我有
@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;
}

当我运行时出现异常,这可能是什么原因?

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)

最佳答案

我已经设法解决了这个问题。

定义为数字的数据库表列声明为 int在实体类中。
我已将它们更改为 Integer问题得到解决。

private Integer deptNo;

public Integer getDeptNo() {
return deptNo;
}

public void setDeptNo(Integer deptNo) {
this.deptNo = deptNo;
}

关于hibernate - 严重:org.hibernate.exception.GenericJDBCException:索引处缺少 IN 或 OUT 参数::1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13804956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com