5 Replies Latest reply on Jan 2, 2012 11:33 PM by lalsamir

    Problem Creating sequence

    lalsamir

      Hello,

      I'm going through the hello world example and I'm getting an error I cannot resolve, that with an auto generated sql statement, that's not valid for postgres 8.1, the database I'm on. Here's my error:

      ......
      17:40:31,370 INFO [STDOUT] Hibernate: select next value for person_id_seq from dual_person_id_seq
      17:40:31,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 42601
      17:40:31,394 ERROR [JDBCExceptionReporter] ERROR: syntax error at or near "value"
      17:40:31,396 FATAL [application] javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not get next sequence value
      javax.faces.el.EvaluationException: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not get next sequence value


      Here's the table definition
      - create table Person (id bigint not null, name varchar(255), primary key (id))
      - create table dual_person_id_seq (zero integer)
      - create sequence person_id_seq start with 1 increment by 1

      and here's the entity bean:

      @Entity
      @Name("person")
      @Table(name="person")
      @SequenceGenerator(name="person_sequence", sequenceName="person_id_seq")
      public class Person implements Serializable {

      private long id;
      private String name;

      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="person_sequence")
      public long getId() { return id;}
      public void setId(long id) { this.id = id; }

      public String getName() { return name; }
      public void setName(String name) { this.name = name; }
      }


      How do I get it to generate a valid sql statement for postgres?