ORA-02289: sequence does not exist when upgrading Hibernate 3 to sleep mode 4

I have a problem with a sequence not found when upgrading hibernate from 3.5 to 4.0.0.RC6:

at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:703) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6] at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:707) [hibernate-core-4.0.0.CR6.jar:4.0.0.CR6] at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:847) [hibernate-entitymana ger-4.0.0.CR6.jar:4.0.0.CR6] ... 159 more Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431) 

Does anyone know how to fix this? please let me know. I am using Oracle10gDialect and overriding the getNativeIdentifierGeneratorClass () function using my own custom SequenceGenerator. It worked on Hibernate 3.5, but threw an exception when I switched to Hibernate 4.0.0.RC6

Below is my TableNameSequenceGenerator class:

 public class TableNameSequenceGenerator extends SequenceGenerator { public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if(params.getProperty(SEQUENCE) == null || params.getProperty(SEQUENCE).length() == 0) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); if(tableName != null) { String seqName = tableName + "_SEQ"; params.setProperty(SEQUENCE, seqName); } } super.configure(type, params, dialect); } } 

When I debug using hibernate 4, tableName returns only REVINFO (it works in sleep mode 3)

Thanks Hiep

+6
source share
2 answers

I have found the answer.

For a generic identifier generator for all classes, we should use

 @Id @GeneratedValue(generator="GENERATOR_COMMON") @GenericGenerator(name="GENERATOR_COMMON",strategy="point.to.table.generator") 

I hope that this help will help those who have the same problem as me.

0
source

Even I have the same problem, use the following lines

 @GenericGenerator(name = "increment", strategy = "increment") @GeneratedValue(generator = "increment") 
0
source

Source: https://habr.com/ru/post/901782/


All Articles