当前位置: 代码迷 >> Oracle开发 >> hibernate3.0 怎么调用oracle10g的存储过程?
  详细解决方案

hibernate3.0 怎么调用oracle10g的存储过程?

热度:82   发布时间:2016-04-24 08:00:29.0
hibernate3.0 如何调用oracle10g的存储过程??
在oracle10g中编写了一个带游标的存储过程,在hibernate3.0中不知该怎么调用啊。
第一种方式:直接用sql的接口,报错信息如下:
Java code
org.hibernate.HibernateException: Exception while trying to autodiscover types.    at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:153)    at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)    at org.hibernate.loader.Loader.doQuery(Loader.java:662)    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)    at org.hibernate.loader.Loader.doList(Loader.java:2145)    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)    at org.hibernate.loader.Loader.list(Loader.java:2024)    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)    at com.onevr.dao.impl.BaseHibernateDao.toProcedure(BaseHibernateDao.java:519)    at com.onevr.dao.impl.statistics.StatDaoImpl.getSelfStat(StatDaoImpl.java:188)    at dao.StatDaoTest.testPesonal(StatDaoTest.java:65)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)    at java.lang.reflect.Method.invoke(Unknown Source)    at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)    at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)    at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)    at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)    at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)    at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)Caused by: java.

第二种方式:
  String sql="{call venture_success(90,100)}";
  ResultSet rs =null;
  Connection conn = null;
  conn = getSession().connection();
  CallableStatement call = conn.prepareCall(sql);
  rs = call.executeQuery();
又总是报错:“无效的sql语句”。


达人指教......

------解决方案--------------------
hib的没有,纯java的有,这事sql:
create or replace procedure proc_sel_stat_total_with_date(
in_start_time varchar2,
in_end_time varchar2,
in_page_size number,
in_start_page number,
out_cr_series OUT SYS_REFCURSOR
)
AS 
begin

open out_cr_series for
select t.series_id,
s.series_name,
t.chapter_id,
c.chapter_no,
t.view_zero_count,
t.view_count,
t.gold_coins
from (
select row_number() over(order by view_count desc) rn,
  相关解决方案