Sequence generation error

I have started getting the following errors suddenly for only few sequences (others are working).

com.microsoft.sqlserver.jdbc.SQLServerException: There is already an object named 'FUND_JOURNAL' in the database.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1676)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:620)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:540)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7620)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3916)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:268)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:242)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:486)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:938)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:1010)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:657)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:569)
	at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2058)
	at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:311)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:280)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:266)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:323)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:294)
	at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:88)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
	at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:812)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3046)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1851)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1833)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1798)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeUpdate(QueryImpl.java:303)
	at io.jmix.eclipselink.impl.JmixEclipseLinkQuery.executeUpdate(JmixEclipseLinkQuery.java:303)
	at io.jmix.data.impl.SequencesImpl.lambda$checkSequenceExists$3(SequencesImpl.java:175)
	at org.springframework.transaction.support.TransactionOperations.lambda$executeWithoutResult$0(TransactionOperations.java:68)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at org.springframework.transaction.support.TransactionOperations.executeWithoutResult(TransactionOperations.java:67)
	at io.jmix.data.impl.SequencesImpl.checkSequenceExists(SequencesImpl.java:167)
	at io.jmix.data.impl.SequencesImpl.lambda$getResult$2(SequencesImpl.java:132)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at io.jmix.data.impl.SequencesImpl.getResult(SequencesImpl.java:131)
	at io.jmix.data.impl.SequencesImpl.createNextValue(SequencesImpl.java:68)
	at com.myapp.mdg.service.NumberGenerationServiceBean.getNextDocNumberWithPrefix(NumberGenerationServiceBean.java:64)

Here " FUND_JOURNAL" is name of the sequence. I have checked database sys.sequence but didn’t find any issues.

ANy suggestions where to check for a fix?

Hello @mortoza_khan !

Could you clarify the version of Jmix and MSSQL server used?
Does additional datastore used?
Are sequences with errors used for entities from additional datastore?

In case of no additional datastore existed and MSSQL 2012+ version, please check next thing:
Does request

select NAME from SYS.SEQUENCES where NAME = 'FUND_JOURNAL'

return any value?

  • If yes: please, check which request of the same form sent to db right before described exception occurs?
    sql logging can be enabled by property logging.level.eclipselink.logging.sql = debug
  • If no: closer look into db is needed.

Regards,
Dmitry

Hi Dmitry
I have resolved it already…It was a matter of Sequence name and table name conflict.

1 Like

Thank you for clarifying the reason of the problem!