A way to not wait for JPA query result in EJB

876 Views Asked by At

i want to know if is there a way to not wait for JPA query result in ejb i have to call a stored procedure whit JPA that make some mass complex treatements on Oracle database, i found javax.ejb.Asynchronous but i don't want to create a thead for that, just call and forget the sotred procedure

Thnaks

1

There are 1 best solutions below

0
On BEST ANSWER

The JDBC API that JPA is typically based on is synchronous, so you cannot achieve what you want without creating a secondary thread to wait for JDBC to return. One alternative would be creating a helper stored procedure in Oracle that just schedules execution of the main stored procedure and returns immediately. Then you would invoke the helper stored procedure from Java.

Sort of:

create or replace procedure schedule_myjob is
begin
    -- search documentation for 
    dbms_job.submit('myjob', ....);
    -- NOTE: dbms_job.submit will not have effect until you commit
    -- your transaction. 
end schedule_myjob;

create or replace procedure myjob is
begin
   -- Your main procedure code
   ...
end myjob;