Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d84cf93

Browse files
authored
Merge pull request #568 from mobilemindtec/7.3.x
Fix class java.lang.Double cannot be cast to class java.lang.Long on ID generation
2 parents 7c10e5a + 494aa40 commit d84cf93

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/engine/MongoCodecEntityPersister.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ class MongoCodecEntityPersister extends ThirdPartyCacheEntityPersister<Object> {
393393
Document result = dbCollection.findOneAndUpdate(new Document(MONGO_ID_FIELD, collectionName), new Document(INC_OPERATOR, new Document(NEXT_ID, 1L)), options)
394394
// result should never be null and we shouldn't come back with an error ,but you never know. We should just retry if this happens...
395395
if (result != null) {
396-
return result.getLong(NEXT_ID)
396+
final nextId = result.get(NEXT_ID, Number.class).longValue();
397+
return Long.valueOf(nextId);
397398
} else {
398399
attempts++
399400
if (attempts > 3) {

0 commit comments

Comments
 (0)