我们正在使用Hibenate 3 jar文件并尝试执行存储过程
@Entity
@NamedNativeQuery(name = "callStoredPrcoc",
resultClass = ProcResult.class,
query = "{call storedProc(?,:inputParam)}",
callable = true,
readOnly=true
)
并获得以下异常。这个错误可能是由Jar文件的版本引起的吗?有没有人得到任何输入有帮助的错误。
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R Caused by: org.hibernate.HibernateException: Problem while trying to load or access OracleTypes.CURSOR value
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.dialect.Oracle9Dialect.registerResultSetOutParameter(Oracle9Dialect.java:309)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1586)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.doQuery(Loader.java:696)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.doList(Loader.java:2228)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.Loader.list(Loader.java:2120)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
[3/29/12 16:30:20:915 CDT] 0000003f SystemErr R at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
答案 0 :(得分:0)
您可以使用SQl查询来调用存储过程
Query query = session.createSQLQuery(
"CALL storedProc(:Parameter)")
.addEntity(Stock.class)
.setParameter("Parameter Name", "value");