title: Spring JPA Lock Table and propagate the transaction
body: <p>I have a class method that extracts some row from the database and sets a lock.</p>
  
  <pre><code>public interface PersonRep extends JpaRepository&lt;Person, String&gt; {
  
      @Lock(LockModeType.PESSIMISTIC_WRITE)
      @Query(value = "SELECT p FROM Person as p WHERE p.fProcessed = false")
      List&lt;Person&gt;  fetchPersonToProccess(@Param("name") String name,Pageable pageable);
  }
  </code></pre>
  
  <p>I have a Service Layer that calls the above method as </p>
  
  <pre><code>@Service
  public class PersonService{
  
      @Override
      @Transactional
      public List&lt;Person&gt; fetchPersonToProccess(String name, Pageable pageable) {
          return personRep.fetchPersonToProccess(name, pageable);      
      }
  }
  </code></pre>
  
  <p>I need to process those result rows into another method of a class without leaving the lock.</p>
  
  <pre><code>@Service
  public class PersonProcess{
      @Transactional
      public List&lt;Person&gt; fetchPersonToProccess(UpdateRequest updateRequest, int numPage){
          //Process Row
          personService.fetchPersonToProccess(..);
      }
  }
  </code></pre>
  
  <p>I would like the lock to be released at the end of the second method into class PersonProcess. How can I do this?</p>