3

I'm trying for the all day long get the Sequence from a Postgres with JPA/Hibernate, but it gives me all the time:

INFO: Hibernate: call next value for tb_cdr_id_seq WARN: SQL Error: 0, SQLState: 42601 ERROR: ERROR: syntax error at or near "call" SEVERE: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet

@Entity
@Table(name = "tb_cdr")
@XmlRootElement
@SequenceGenerator(name = "tb_cdr_id_seq", sequenceName = "tb_cdr_id_seq", allocationSize=1)
public class Cdr implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_cdr_id_seq")
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
....

}

the Postgres version is 9.2 and don't have the function: call next value.... like Hibernate is print...

What should I do ?

Thanks

2
  • Please show the SQL Hibernate is generating and the full, exact error. See the PostgreSQL logs (log_statement = on) or Hibernate logs. At a guess, you might be using the wrong SQL dialect setting, or the sequence tb_cdr_id_seq doesn't exist. Commented Jun 20, 2013 at 23:47
  • <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> done the trick! Tks Commented Jun 21, 2013 at 14:24

1 Answer 1

4

Hibernate wasn't auto-detecting the dialect or it was being overridden. Setting hibernate.dialect explicitly to org.hibernate.dialect.PostgreSQLDialect resolved the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.