title: Update query spring data JPA modifies all columns
body: <p>I'm trying to update table based on Id that user passes from UI.</p>
  
  <p><strong>Problem statement example</strong> : when user sends Id as 1 then table should be updated only one row with other few parameters like lastModifiedBy and deleted where as my code updates all rows in table,</p>
  
  <p><strong>orm.xml</strong></p>
  
  <pre><code>&lt;entity class="com.example.Domain" name="Domain"&gt;
      &lt;table name="t_table"/&gt;
      &lt;attributes&gt;
          &lt;id name="id"&gt;
              &lt;column name="ID" nullable="false"/&gt;
              &lt;generated-value strategy="SEQUENCE" generator="S_GEN"/&gt;
              &lt;sequence-generator name="S_GEN" sequence-name="S_GEN" allocation-size="1"/&gt;
          &lt;/id&gt;
          &lt;basic name="deleted"&gt;
              &lt;column name="DELETED" nullable="false" length="5"/&gt;
          &lt;/basic&gt;
          &lt;basic name="lastModifiedBy"&gt;
              &lt;column name="LAST_MODIFIED_BY" nullable="false" length="100"/&gt;
          &lt;/basic&gt;
      &lt;/attributes&gt;
  </code></pre>
  
  <p>       </p>
  
  <p><strong>Entity class</strong></p>
  
  <pre><code>@Data
  @Builder
  @NoArgsConstructor
  @AllArgsConstructor
  public class Domain {
      private Long id;
      private boolean deleted;
      private String lastModifiedBy;
  }
  </code></pre>
  
  <p><strong>JPA Repository:</strong></p>
  
  <pre><code>    public interface JpaDomainRepository extends Repository&lt;Domain, Long&gt; {
          @Modifying
          @Query(value = "update Domain set DELETED = true, LAST_MODIFIED_BY = lastModifiedBy where id = id")
          int update(Domain domain);
  }   
  </code></pre>
  
  <p><strong>Service Class</strong></p>
  
  <pre><code>public void update(UpdateCommand command) {
      Domain domain = repository.findByIdAndDeletedFalse(command.getID());
      domain.setLastModifiedOn(command.getLastModifiedOn());
      domain.setLastModifiedBy(command.getLastModifiedBy());
      repository.update(domain);
  }
  </code></pre>
  
  <p>If table is having multiple entries already and I'm trying to update first row then rest all rows are getting modified,</p>
  
  <p>In-short notation my update query is always true for where clause like below,</p>
  
  <p>Example for input 1, only one column where id = 1 should get modify but query is modifying rows 2, 3 and so on as well,</p>
  
  <pre><code>update Domain set DELETED = true, LAST_MODIFIED_BY = lastModifiedBy where 1= 1
  </code></pre>
  
  <p>Why is it behaving like so and what could be solution?</p>
  
  <p>PS:
  I don't want to pass ID explicitly from service class since I id is already available in domain object.</p>