Hi,
According to the docs, there is support for Sequences for SQL Server. I see it as well in the org.datanucleus.store.rdbms.adapter.SQLServerAdapter class. However, when I configure my Model with the necessary sequence details, I get an exception thrown:
@PersistenceCapable
@DatastoreIdentity(strategy= IdGeneratorStrategy.SEQUENCE, sequence="toto" )
@Sequence(name="toto", datastoreSequence = "jdo_sequence", strategy=NONTRANSACTIONAL)
public class Organization {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
2021-03-10 21:32:53,085 DEBUG [http-nio-9080-exec-1] DataNucleus.Datastore.Native: SELECT NEXT VALUE FOR 'POC_DATANUCLEUS.DBO.JDO_SEQUENCE'
2021-03-10 21:32:53,092 DEBUG [http-nio-9080-exec-1] DataNucleus.Datastore: Closing PreparedStatement "org.datanucleus.store.rdbms.ParamLoggingPreparedStatement@4c38e3c6"
2021-03-10 21:32:53,092 INFO [http-nio-9080-exec-1] DataNucleus.ValueGeneration: Error encountered allocating block of IDs : Couldnt obtain a new sequence (unique id) : Incorrect syntax near 'POC_DATANUCLEUS.DBO.JDO_SEQUENCE'.
If I look in the code itself, I see the following comment on line 651:
// Do we need to quote the sequence name here?
StringBuilder stmt = new StringBuilder("SELECT NEXT VALUE FOR '");
stmt.append(sequenceName);
stmt.append("'");
From my quick tests, I see that the error is indeed caused by the 'quoting' of the sequence name.
This makes me wonder if it is my configuration which is incorrect, or if support for MS SQL Sequences has never really been tested? Is there full support for SqlServer Sequences? Is it just my configuration which is wrong?
Thanks,
Eric