This will happen if you have two sessions (in your case, Java threads) that are trying to insert the same ORDER_REF_ID. Consider the following scenario:
1) 1 MERGE ( ):
merge into ORDER_LOCK al
using ( select 1 ORDER_REF_ID, sysdate ORDER_MSG_SENT from dual ) t
on (al.ORDER_REF_ID = t.ORDER_REF_ID)
when not matched then
insert (ORDER_ID, ORDER_REF_ID, ORDER_MSG_SENT)
values (ORDER_LOCK_SEQ.nextval, t.ORDER_REF_ID, t.ORDER_MSG_SENT);
2) 2 MERGE:
merge into ORDER_LOCK al
using ( select 1 ORDER_REF_ID, sysdate ORDER_MSG_SENT from dual ) t
on (al.ORDER_REF_ID = t.ORDER_REF_ID)
when not matched then
insert (ORDER_ID, ORDER_REF_ID, ORDER_MSG_SENT)
values (ORDER_LOCK_SEQ.nextval, t.ORDER_REF_ID, t.ORDER_MSG_SENT);
( , 2 " 1. 2 , , 1):
3) 1
= > 2 , ORA-00001: , ORDER_REF_ID 1
UPDATE
, Java ORDER_REF_IDs - ORDER_REF_ID "" , / ORDER_REF_ID.