title: Autoincrement does not work PostgreSQL - Java EE APP
body: <p>I have application in which I have autoincrement for PK Id. I had to add other autoincremented column and I used liquibase to make it work - liquibase created sequence for auto increment. When I make insert from query tool or when i do not map this field in entity and make persist autoincrement works. But when I add :</p>
  
  <pre><code>@GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "next_value", nullable=false, unique=true)
  private Long nextValue;
  </code></pre>
  
  <p>I get an ugly error: </p>
  
  <pre><code>Caused by: org.postgresql.util.PSQLException: ERROR: empty value in the "next_value" column violates the limit of the required value
  </code></pre>
  
  <p> 
  What is wrong here?</p>
  
  <p>EDIT:</p>
  
  <p>My liquibase changeset to add this column and make it autoincrement: </p>
  
  <pre><code>&lt;addColumn tableName="table"&gt;
        &lt;column name="next_value" type="number"/&gt;
      &lt;/addColumn&gt;
  &lt;addAutoIncrement
          columnDataType="number"
          columnName="next_value"
          incrementBy="1"
          startWith="1"
          tableName="table"/&gt;
  &lt;sql&gt;select setval('table_next_value_seq', (select cast(current_value+1 as bigint) from gapless_sequence), false)&lt;/sql&gt;
  </code></pre>
  
  <p>setval was used to start it not from 1</p>