简体   繁体   中英

hibernate PLS-00306 error

I have a legacy procedure on db, and I cannot modify it. It looks like this:

create or replace FUNCTION  GETSESSION
   ( sUsername IN varchar) return varchar
   IS
     nSession number;
     sRAWString   RAW (32767);
     sKey varchar(60);
     sKey2 varchar(60);
BEGIN
    select webservice.seq_mgmt.NEXTVAL, sys_guid() into nSession, sKey2 from dual;
    sRAWString   := UTL_RAW.CAST_TO_RAW (sKey2);
    sKey:=LOWER(SYS.DBMS_CRYPTO.HASH (sRAWString, SYS.DBMS_CRYPTO.HASH_MD5));
    update mgmt_session s set s.loggedout = sysdate where upper(s.userid) = upper(sUsername) and loggedout is null;
    insert into mgmt_session a (userid, sessionid, token, loggedin)
                        (select upper(susername), nSession, sKey, sysdate from dual);
    return sKey2;
END;

Along with this, I also has legacy code, that thankfully, I can and should modify to make it pretty. So I want to change direct call to database procedure to hibernate call, but I ran into error PLS-00306 that claims I have wrong number or type of arguments.

here is my call:

StoredProcedureQuery query = entityManager.createStoredProcedureQuery("GETSESSION")
                .registerStoredProcedureParameter(1, String.class, ParameterMode.IN)
                .registerStoredProcedureParameter(2, String.class, ParameterMode.OUT)
                .setParameter(1, username);

        query.execute();
        return (String) query.getOutputParameterValue(2);

I know what error message cays - I just can't understand what's wrong with my parameters setting :/ This procedure takes one string, and returns other string. Or am I wrong?

输出参数为2。使用query.getOutputParameterValue(2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM