title: How can I prevent duplicated insert in oracle database with Java?
body: <p>Let me give the example first. It is a log table.</p>
  
  <p>User A subscribe the service A = OK <br/>
   User A unsubscribe the service A = OK <br/>
   User A subscribe the service A again = OK <br/>
   User A subscribe the service A again = <b>Not OK</b>, because you can't subscribe same service at the same time.</p>
  
  <p>Sometimes the client goes crazy and send 5 subscribe requests at the same time ( 4 tomcat servers behind), if I do nothing in this situation then 5 same records will be inserted.</p>
  
  <p>As you can see, I can't use unique constraint here.
  I guess perhaps I can use some single thread block in Oracle, but not sure..
  I tried "merge" , but I guess it is used in specific records instead of last record. </p>
  
  <p>begin single thread</p>
  
  <ol>
  <li>select the last record </li>
  <li>if the <b>last record</b> is the same then don't insert.</li>
  <li>if the <b>last record is</b> not the same then insert.
  end single thread<br/></li>
  </ol>
  
  <p>Is it possible and how to achieve ? </p>