title: Spring data JPA native query skip locked
body: <p>I want to execute a <code>SKIP LOCKED</code> query on Oracle using Spring Data JPA, so I tried the following:</p>
  
  <pre><code>@Lock(LockModeType.PESSIMISTIC_WRITE)
  @Query(value = "SELECT * FROM User WHERE ID=?1 FOR UPDATE SKIP LOCKED", nativeQuery = true)
  User findOne(UUID id);
  </code></pre>
  
  <p>I tried the above and found that the generated query contains <code>FOR UPDATE</code>, but not <code>SKIP LOCKED</code> (below is the generated query from logs):</p>
  
  <pre><code>select ent0_.column1 as name, ent0_.CREATED_DATE as CREATED_2_33_0_ from TABLE_NAME alias_name where ent0_.column1=? for update
  </code></pre>
  
  <p>If I remove <code>@Lock</code> from the query method, the generated query does not even have <code>FOR UPDATE</code>.</p>
  
  <p>Please suggest how I can generate a query with <code>FOR UPDATE SKIP LOCKED</code>, as required.</p>