[jboss-user] [EJB 3.0] - Problem Creating sequence

lalsamir do-not-reply at jboss.com
Sun Oct 12 15:08:57 EDT 2008


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? 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4181708#4181708

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4181708



More information about the jboss-user mailing list