Hi, i need help with Hibernate Version 3.1.2 and Annotations 3.1.8. I am using an Oracle 9i Database. I have the following error when trying to use a generated sequence for the id of my table.
Hibernate: select my_sequence.nextval from dual
2906 WARN JDBCExceptionReporter - SQL Error: 2289, SQLState: 42000
2906 ERROR JDBCExceptionReporter - ORA-02289: sequence does not exist
org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:531)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:519)
at hiberAnnoTest.test.main(test.java:37)
Caused by: java.sql.SQLException: ORA-02289: sequence does not exist
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
My Code looks like this.
@javax.persistence.SequenceGenerator(
name = "SEQ_GEN",
sequenceName="my_sequence"
)
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SEQ_GEN")
public Long getId() {
return id;
}
Do anyone know how to handle this? I am new with annotations and i didn`t found any explanation in the manual for this problem. I also tried GeneratorType.AUTO, and .IDENTITY and .TABLE
EDIT:Before this i used Hibernate with XDoclet and generator-class="increment" which worked fine
|