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:
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.
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.
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
Post a Comment