jpa - how to call oracle stored procedure in jpa2.0 which returns integer as out variable -


i have written 1 stored procedure return integer value. not able count in jpa. can 1 suggest me way call stored procedure , return out value variable in java using jpa.

int count = 0; string id = "m123"  count = getem().createnativequery("call sample_procedure(?,?)")                     .setparameter(1, id)                     .setparameter(2, count)                     .executeupdate(); 

stored procedure: have logic in procedure , inside loop incrementing count.

    create or replace procedure sample_procedure(     id in varchar,     count out number)   ........ begin .....  loop ---------  count := count + 1; 

looks similar answer

options tried:

  1. tried curly braces before call statement.

    query q = entitymanager.createnativequery("{call sample_procedure(?,?)}").setparameter(1, inparam).setparameter(2, outparam);

    q.executeupdate();

it did not work. did not return output java class.

  1. tried this:

    query q = entitymanager.createnativequery("{call sample_procedure(?,?)}", integer.class).setparameter(1, inparam).setparameter(2, outparam);

    q.executeupdate();

it did not work either. did not return output java class.

  1. tried well:

    query q = entitymanager.createnativequery("{call sample_procedure(?,?)}").setparameter(1, inparam).setparameter(2, outparam);

    q.getsingleresult();

this threw exception: cannot perform update or delete operation on select query: "{call sample_procedure(?,?)}".

i believe not possible mentioned sean patrick floyd in answer link have provided above.(note: not have book :)) if need process out parameter , if reason need it, need handle logically. seems not possible in jpa2.0


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -