-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to pass Object Array to Oracle Stored Proc thr hibernate
PostPosted: Thu Mar 04, 2010 8:19 am 
Newbie

Joined: Wed Mar 03, 2010 11:01 am
Posts: 1
Hi,

I'm trying to pass an Java Object Array to an Oracle Stored Procedure thro' hibernate,
It gives me the following error,

======================================================================
Hibernate: {call Contact_OBJ_ARRAY_PROC(?, ?)}
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:3703)
at oracle.jdbc.driver.OraclePreparedStatement.setNullInternal(OraclePreparedStatement.java:3594)
at oracle.jdbc.driver.OracleCallableStatement.setNull(OracleCallableStatement.java:4162)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:147)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:1778)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1704)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1723)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.citi.pscu.transaction.dao.TransactionDaoImpl.sendObjectToOracle(TransactionDaoImpl.java:418)
======================================================================
These are my code samples

My DAOImpl Class
-----------------
public String sendObjectToOracle() {
Contact contactArray[] = new Contact[1];
Contact contact = new Contact();
contact.setEmpno(100);
contact.setEname("Navalur");
contactArray[0] = contact;

Query qry=this.getSession().getNamedQuery("callPSCUBankNames");
qry.setParameterList("p1",contactArray);
qry.list();
}

my hbm file
-----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.citi.pscu.transaction.dao.Contact" table="EMP">

<id name="empno" type="int"/>
<property name="ename" type="java.lang.String"/>
<loader query-ref="callPSCUBankNames" />
</class>

<sql-query name="callPSCUBankNames" callable="true">
{call Contact_OBJ_ARRAY_PROC(:p1)}
</sql-query>

</hibernate-mapping>


On the Oracle Side
==============
1)
create or replace TYPE Contact_OBJ AS OBJECT (
EMPNO number,
ENAME varchar2(20)
)

2)
create or replace type Contact_OBJ_ARRAY as table of Contact_OBJ

3)Procedure which i'm calling

create or replace PROCEDURE
Contact_OBJ_ARRAY_PROC (p_obj_array in Contact_OBJ_ARRAY)
AS

BEGIN
DBMS_OUTPUT.PUT_LINE('SIVA');
ERR_DEBUG('testing for array--->',sysdate,'1----->',null,null,null);

for i in 1 .. p_obj_array.count
loop
ERR_DEBUG(null,p_obj_array(i).ename,null,null,null,null);
dbms_output.put_line(p_obj_array(i).ename);

end loop;

END Contact_OBJ_ARRAY_PROC;

======================================================================

I did not know how to configure the Oracle Object Type in Hibernate

I'm able to call the procedure thro PreparedStatement but not able to call when i'm using org.hibernate.Query

setParamater("","')
and list() methods.

can anyone help me out on this.

thanks,
vijay.


Top
 Profile  
 
 Post subject: Re: How to pass Object Array to Oracle Stored Proc thr hibernate
PostPosted: Wed Jul 29, 2015 2:55 pm 
Newbie

Joined: Wed Jul 29, 2015 2:53 pm
Posts: 1
Do you got any answers on how to do it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.