title: spring crudrepository save with specific id
body: <p>I want to insert(not update) data to my repository with specific id's, but whenever I do that Id's are ignored and the inserted entries have simply the next id in the sequence. </p>
  
  <pre><code>Entity entity = new Entity();
  entity.setId(4l);
  //..
  Entity saved = repository.save(entity);
  System.out.println(saved.getId()); // is 1l
  </code></pre>
  
  <p>Here's how my setup looks like</p>
  
  <pre><code>@Entity
  @Table(name = "ENTITY")
  public class Entity {
  
      @Id
      @Column(name = "ID")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
     //...
  
  }
  
  @Repository
  public interface SomeRepository extends CrudRepository&lt;Entity, Long&gt; {
  
  }
  </code></pre>
  
  <p>I also tried changing the generation strategy to <code>AUTO</code> but then I get </p>
  
  <p><code>Table 'embedded-db.hibernate_sequence' doesn't exist</code></p>
  
  <p>How can I insert data with specific ID while also allowing the id's to be generated?</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>Ok, so I found out that one of the solutions is forcing to use a specific sequence for generating the id and using generation strategy <code>AUTO</code> like this:</p>
  
  <pre><code>@Id
  @Column(name = "ID")
  @GeneratedValue(strategy=GenerationType.AUTO, generator="my_seq_gen")
  @SequenceGenerator(name="my_seq_gen", sequenceName="actual_seq_name")
  private Long id;
  </code></pre>
  
  <p>However I use <code>mariaDb</code> for my test env and it does not support sequences, so this solution does not work for me. Is there any other way to do this?</p>