-->
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: Getting exception while passing List<Long> from hibernate to
PostPosted: Wed Nov 02, 2016 3:17 am 
Newbie

Joined: Wed Nov 02, 2016 3:01 am
Posts: 2
Hi,

I need to pass List<Long> from hibernate to my stored procedure. Below is the code for the same -

Here is my query:

Code:
Query q = getSession().getNamedQuery("cloneSpecialClauses")
                .setLong("grpId",groupId)
                .setLong("maId",maId)
                .setLong("amdId",amdId)
                .setString("user",user)
                .setParameterList("deleted_spc_ids",deleted_spc_ids)
               .setParameterList("updated_spc_ids",updated_spc_ids);
              q.uniqueResult();


Code:
<sql-query name="cloneClauses" callable="true">
        { call clone_clause( :grpId, :maId, :amdId, :user, :deleted_spc_ids, :updated_spc_ids) }
    </sql-query>


My oracle stored procedure looks like this:

Code:
CREATE OR REPLACE TYPE t_in_list AS TABLE OF NUMBER;
CREATE OR REPLACE PROCEDURE clone_clause (

   grpid   NUMBER,
   maid    NUMBER,
   amdid   NUMBER,
   cuser   VARCHAR2,
   deleted_spc_ids t_in_list,
   updated_spc_ids t_in_list
   
)

AS

BEGIN
 
   FOR elem in 1 .. deleted_spc_ids.count LOOP
   
   DELETE FROM  abc th
         WHERE th.ma_id IN (SELECT ma_id
                              FROM def
                             WHERE ma_id <> maid AND grp_id = grpid)
           AND th.amd_id = amdid
           AND th.spc_cla_id = deleted_spc_ids(elem);
    END LOOP;
     
     
    FOR elem1 in 1 .. updated_spc_ids.count LOOP
     
    UPDATE abc  c1
      SET is_applicable =
       (select is_applicable from abc where ma_id=maid
       and spc_cla_id=updated_spc_ids(elem1)),
          date_modif = SYSDATE,
          user_modif = cuser
    WHERE ma_id IN (SELECT ma_id
                      FROM def
                     WHERE ma_id <> maid AND grp_id = grpid)
          AND amd_id = amdid
          AND spc_cla_id = updated_spc_ids(elem1);
           
     END LOOP;
     
     
               
END;


Exception:

Code:
PLS-00306: wrong number or types of arguments in call clone_clause


Is there something wrong with my stored procedure or the way i am passing the List to my stored procedure?


Top
 Profile  
 
 Post subject: Re: Getting exception while passing List<Long> from hibernate to
PostPosted: Wed Nov 02, 2016 5:27 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Instead of:

Code:
setParameterList("deleted_spc_ids",deleted_spc_ids)
.setParameterList("updated_spc_ids",updated_spc_ids);


Try with:

Code:
setParameter("deleted_spc_ids",deleted_spc_ids, ObjectType.INSTANCE)
.setParameter("updated_spc_ids",updated_spc_ids, ObjectType.INSTANCE);


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.