Exception with sequences in v3.0

We just started the migration from 2.2 to 3.0. We do have some code that used to work in v2.2 but apparently it does not work in v3.0. In particular, we have some old code that generates unique IDs in a sequence as follows:

	OMetadata md = this.graph.getRawGraph().getMetadata();
	OSequenceLibrary sequenceLibrary = md.getSequenceLibrary();
	OSequence seq = 
			sequenceLibrary.getSequence( seqName );
	if( seq == null ) {
		seq = sequenceLibrary.createSequence(seqName, SEQUENCE_TYPE.ORDERED, new OSequence.CreateParams().setStart(0L));
	long next = seq.next();
	return next;

In v3.0 the line long next = seq.next(); gives this exception:

com.orientechnologies.orient.core.exception.ORecordNotFoundException: The record with id ‘#-1:-2’ was not found
DB name=“test-db”
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.reload(ODatabaseDocumentAbstract.java:1172)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.reload(ODatabaseDocumentAbstract.java:85)
at com.orientechnologies.orient.core.record.ORecordAbstract.reload(ORecordAbstract.java:260)
at com.orientechnologies.orient.core.record.ORecordAbstract.reload(ORecordAbstract.java:251)
at com.orientechnologies.orient.core.record.impl.ODocument.reload(ODocument.java:1021)
at com.orientechnologies.orient.core.metadata.sequence.OSequence.reloadSequence(OSequence.java:267)
at com.orientechnologies.orient.core.metadata.sequence.OSequence.callRetry(OSequence.java:292)
at com.orientechnologies.orient.core.metadata.sequence.OSequenceOrdered.next(OSequenceOrdered.java:60)

Any idea on how to fix it?

#-1:-2 is a temporary Record ID due to the beginning of the transaction. At commit time, thsi temporary Record ID will be converted in the final one.


I know. And making tests I saw that adding an explicit commit() after sequence creation avoids the exception. But why in 2.2 it works fine without commit? Is this documented somewhere?