-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: working with Oracle varrays
PostPosted: Thu Jul 06, 2006 11:26 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
I'm testing the DAO I created with Hibernate Generic DAO but I'm unable to manipulate Oracle VARRAYs in Hibernate. Does Hibernate supports this type of collection in Oracle? Can I just annotate a column with oracle.sql.ARRAY type? Here are some details might be useful to help me.

Code:
PrivilegeDAOImpl dao = (PrivilegeDAOImpl)factory.getPrivilegeDAO();
Integer[] accs = new Integer[10];
for(int i=1; i<11; i++) accs[i-1] = new Integer(i);
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("PRIV_TYPE", dao.getSession().connection());
ARRAY array = new ARRAY(desc, dao.getSession().connection(), accs);
Privilege priv = new Privilege();
priv.setDescription("admin");
priv.setAccessibles(array);
dao.startTx();
Privilege p = dao.save(priv);
dao.closeTx();
assertEquals(priv, p);




Full stack trace of any exception that occurs:


java.lang.ClassCastException: $Proxy21
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:148)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:114)
at com.proit.tests.HibernateUtilTest.testPrivilege(HibernateUtilTest.java:54)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Name and version of the database currently using: Oracle 10g


Top
 Profile  
 
 Post subject: bump!
PostPosted: Tue Jul 11, 2006 11:59 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
bump!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 12:16 pm 
Newbie

Joined: Mon Feb 05, 2007 12:14 pm
Posts: 2
Location: Peru
Hi!

I had the same problem in the last week, and found the solution,
The ArrayDescriptor and ARRAY needed a Native Connection, and the mode to get this is:

cstmt = (OracleCallableStatement) getSession().connection().prepareCall(" call REP_UPDATE_STOCK_WAREHOUSE(?, ?, ?, ?, ?) ");

ArrayDescriptor descCE = ArrayDescriptor.createDescriptor("NUMBER_NT", cstmt.getConnection() );

A OracleCallableStatement.getConnection returns a Native Connection... use that for parameter the ArrayDescriptor.createDescriptor and the ClassCastException will solve.

_________________
____________________________
Richard C. De los Reyes PrĂ­ncipe
Lima - PerĂș


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 5:51 am 
Newbie

Joined: Thu Jan 22, 2009 5:01 am
Posts: 1
Hi, I try to use (OracleCallableStatement), but got the following error. It seems the case is still fail. And I also use "OracleConnection conn = (OracleConnection) session.connection();", but it got $ProxyXX error too.


Code:
org.hibernate.SessionFactory sessionFactory = getHibernateTemplate().getSessionFactory();
org.hibernate.Session session = sessionFactory.openSession();
String[] javaArray1 = {"AAAA","BBB"};
OracleCallableStatement stmt = (OracleCallableStatement) session.connection().prepareCall("SELECT * FROM table WHERE name IN (SELECT * FROM TABLE (CASE(? as NAME_LIST)) )");
ArrayDescriptor oracleCollection = ArrayDescriptor.createDescriptor("NAME_LIST", stmt.getConnection());
ARRAY jdbcArray1 = new ARRAY(oracleCollection, stmt.getConnection(), javaArray1);
stmt.setObject(1, jdbcArray1);
ResultSet r = stmt.executeQuery();
while(r.next()){
  System.out.println("OUTPUT: " + r.getString(1));
}


Error message:
[ERROR] RuntimeException Error Message : org.apache.commons.dbcp.DelegatingCallableStatement
java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingCallableStatement
at com.test.webservice.fun1.getPartStatus(PartInfoDAOImpl.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3395)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.