title: How to avoid select statement during save in Spring Data JPA
body: <p>I have a composite primary key (made of 3 columns) for an entity.</p>
  
  <p>Out of 2 columns from the composite key, 1 is auto increment and another is getting populated from another entity.</p>
  
  <p>when I save the entity, it executes select statement and then insert statement. 
  I want to ignore/avoid execution of select statement as I know that the entity are unique and simply want to insert into the table.</p>
  
  <p>I read about having a field with @Version (like <code>@Version Long version</code>) in the entity however, in that case, I will have to have a column on the table as well which I don't want.</p>
  
  <p>The execution of select statement taking lots of time especially when I know that the records I am inserting are unique.</p>
  
  <p>[EDITED]</p>
  
  <p>my entity class is:</p>
  
  <pre><code>@Entity
  public class Table implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @EmbeddedId
      private TablePK id;
  
      private String Name;
  
      private String country;
  }
  
  @Embeddable
  public class TablePK implements Serializable {
      //default serial version id, required for serializable classes.
      private static final long serialVersionUID = 1L;
  
      @GeneratedValue(strategy=GenerationType.AUTO)
      private Long id;
  
      private Integer age;
  }
  </code></pre>
  
  <p>and the log is:</p>
  
  <pre><code>10:39:57.650 [main] DEBUG org.hibernate.SQL - select 
  10:39:57.684 [main] DEBUG org.hibernate.loader.Loader - Done entity load
  10:39:57.693 [main] DEBUG o.h.e.i.AbstractSaveEventListener - Generated identifier: 
  10:39:57.705 [main] DEBUG o.h.e.t.internal.TransactionImpl - committing
  10:39:57.706 [main] DEBUG o.h.e.i.AbstractFlushingEventListener - Processing flush-time cascades
  10:39:57.707 [main] DEBUG o.h.e.i.AbstractFlushingEventListener - Dirty checking collections
  10:39:57.709 [main] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
  10:39:57.709 [main] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
  10:39:57.710 [main] DEBUG o.h.internal.util.EntityPrinter - Listing entities:
  10:39:57.726 [main] DEBUG org.hibernate.SQL - insert into Table
  </code></pre>
  
  <p>Can anyone please suggest.</p>