title: Getting next value from sequence with jpa repository in postgreSQL
body: <p>I've seen the similar question, but in my situation it doesn't work.
  I need to get the next value of the sequence.</p>
  
  <p>Model class:</p>
  
  <pre><code>@Entity
  @Table(name = "item")
  public class Item {
      @Id
      @SequenceGenerator(name = "id_seq", sequenceName = "item_id_seq", allocationSize = 1)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_seq")
      @Column(name = "id", updatable = false)
      protected Long id;
  }
  </code></pre>
  
  <p>Jpa Repository:</p>
  
  <pre><code>public interface ItemRepository extends JpaRepository&lt;Item, Long&gt; {
      List&lt;Item&gt; findFirst10ByOrderByPublicationDateDesc();
  
      @Query(value = "SELECT item_id_seq.nextval FROM item", nativeQuery = 
      true)
      Long getNextSeriesId();
  }
  </code></pre>
  
  <p>I would appreciate any help.</p>