title: Set lock timeout programmatically Spring Boot JPA
body: <p>I have </p>
  
  <pre><code>@Transactional(timeout = 600)
  @Service
  public class CustomerServiceImpl implements CustomerService {
  
      @Autowired
      private CustomerRepository customerRepository;
  
      @Override
      public void actOnCustomer(Long customerId) {
      ...
  </code></pre>
  
  <p>along with </p>
  
  <pre><code>public interface CustomerRepository extends CrudRepository&lt;Customer, Long&gt; {
  
      @Lock(LockModeType.PESSIMISTIC_WRITE)
      Optional&lt;Customer&gt; findById(Long id);
  </code></pre>
  
  <p>The customer row seems to be getting locked, and the timeout value seems to be having the proper effect. </p>
  
  <p><em>Now I want to be able to set the timeout value programmatically, and/or using my application.properties file</em>.  I've seen some examples of setting <code>javax.persistence.lock.timeout</code> in properties passed to an <code>EntityManager</code>'s <code>find</code> method, but I'm not sure of how best to incorporate <code>EntityManager</code> calls into a Spring repository, and it seems like there should be a more Spring-y way (like setting <code>spring.jpa.properties.javax.persistence.lock.timeout=600</code> in application.properties, which doesn't seem to work).</p>
  
  <p>So how do I do this?  </p>