title: Concurrency and JPA repository behaviour
body: <p>I have 2 Entities mapped with JPA</p>
  <pre><code>@Entity
  class Table_A {
  
    @Id
    private Integer id;
  
    @Enumerated(EnumType.STRING)
    private ModuleType module;
  
    private String name;
  
    private Instant lastModifiedDate; 
  
    private String creator;
  
    @NotNull
    @Enumerated(EnumType.STRING)
    private State state;
    
    @OneToMany(fetch = FetchType.LAZY)
      @JoinColumns( value = {
        @JoinColumn(name=&quot;id_object&quot;, referencedColumnName = &quot;id_entity&quot;, insertable = false, updatable = false),
        @JoinColumn(name=&quot;object_sub_type&quot;, referencedColumnName = &quot;object_sub_type&quot;, insertable = false, updatable = false),
    }, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private List&lt;AttributeValue&gt; attributes;
  }
  
  
  @Entity
  Class Table B {
  @Id
    private Integer id;
  
    @Column(name = &quot;id_create_user&quot;, insertable = false, updatable = false)
    private String createUser;
  
    @Column(name = &quot;type_object&quot;, insertable = false, updatable = false)
    private String typeObject;
  
  
    @Column(name = &quot;id_object&quot;, insertable = false, updatable = false)
    private Integer idTable_A;
  
    @Column(name = &quot;name&quot;)
    private String name;
  
    private Boolean hasCombination;
  }
  </code></pre>
  <p>The entities are not related. And also I have a JPARepository interface for each one.</p>
  <pre><code>@Repository
  public interface Table_A_Repository extends JpaRepository&lt;Table_A, Integer&gt;
  @Repository
  public interface Table_B_Repository extends JpaRepository&lt;Table_B, Integer&gt;
  </code></pre>
  <p>When I have 2 threads.</p>
  <p>The first one Thread_1 read an object of &quot;Table_A&quot; make some operations and modify one field of the table_A object</p>
  <p>The second Thread_2 read the same object from Table_A and makes changes on different rows of Table_B ( Table_B_Repository.saveAll( listOfTable_Bobjects) ) before Thread_1 has finished.</p>
  <p>I see than Thread_2 override the change of Thread_1 in Table_A object.</p>
  <p>What I don't understand is why calling Table_B_Repository.saveAll makes and update in table_A overriden the value set in the first thread, leaving it as it was.</p>
  <p>thanks for your responses or comments.</p>