Skip to content

Conversation

codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Oct 8, 2025

This really needs to go out in 7.0.0 as it is currently completely broken

This is the isolated part of PR #15118 that fixes #15120

All it does is mark properties annotated with @AutoTimestamp dirty so they are guaranteed to be saved during updates.

To see existing non behavior:

git clone --depth 1 --single-branch https://github.com/codeconsole/mongo-test mongo-test-RC2 && cd mongo-test-RC2 && ./gradlew bootRun

Create and Edit to see modified not updated after edit save.
http://localhost:8080/user/create
http://localhost:8080/user/edit/1

The checkout grails-core fix branch and publish it to mavenLocal

git clone --depth 1 --branch 7.0.x-autotimestamp-mongo-fix https://github.com/codeconsole/grails-core grails-core-autotimestamp-mongo-fix && cd grails-core-autotimestamp-mongo-fix && ./gradlew pTML

You can verify fix on MongoDb

git clone --depth 1 --branch mongodb-mavenLocal-7.0.0-SNAPSHOT https://github.com/codeconsole/mongo-test mongo-test-mongo-SNAPSHOT && cd mongo-test-mongo-SNAPSHOT && ./gradlew bootRun --args='--server.port=8081'

http://localhost:8081/user/create
http://localhost:8081/user/edit/1

You can verify fix also works on Hibernate

git clone --depth 1 --branch h2-mavenLocal-7.0.0-SNAPSHOT https://github.com/codeconsole/mongo-test mongo-test-hibernate-SNAPSHOT && cd mongo-test-hibernate-SNAPSHOT && ./gradlew bootRun --args='--server.port=8082'

http://localhost:8082/user/create
http://localhost:8082/user/edit/1

@github-actions github-actions bot added the bug label Oct 8, 2025
@codeconsole codeconsole force-pushed the 7.0.x-autotimestamp-mongo-fix branch from 9391558 to bc1808a Compare October 8, 2025 18:33
@codeconsole codeconsole changed the title 7.0.0-RC2 - @Autotimestamp Persistence Bug Fix 7.0.0-RC2 BUG FIX - @Autotimestamp Mongo Persistence Oct 8, 2025
@codeconsole
Copy link
Contributor Author

codeconsole commented Oct 9, 2025

In Summary

All this does is make @AutoTimestamp properties dirty if there are changes so they will be persisted. It doesn't affect anything else. You can verify everything working on both hibernate and mongo in just 3 commands.

Publish fix to mavenLocal()

git clone --depth 1 --branch 7.0.x-autotimestamp-mongo-fix https://github.com/codeconsole/grails-core grails-core-autotimestamp-mongo-fix && cd grails-core-autotimestamp-mongo-fix && ./gradlew pTML

Run fix on port 8081 for mongo and 8082 for hibernate in 2 command

git clone --depth 1 --branch mongodb-mavenLocal-7.0.0-SNAPSHOT https://github.com/codeconsole/mongo-test mongo-test-mongo-SNAPSHOT && cd mongo-test-mongo-SNAPSHOT && ./gradlew bootRun --args='--server.port=8081'

git clone --depth 1 --branch h2-mavenLocal-7.0.0-SNAPSHOT https://github.com/codeconsole/mongo-test mongo-test-hibernate-SNAPSHOT && cd mongo-test-hibernate-SNAPSHOT && ./gradlew bootRun --args='--server.port=8082'

http://localhost:8081/user/create
http://localhost:8082/user/create

@codeconsole codeconsole changed the title 7.0.0-RC2 BUG FIX - @Autotimestamp Mongo Persistence 7.0.0-RC2 BUG FIX - @AutoTimestamp Mongo Persistence Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7.0.0-RC2: @AutoTimestamp and lastUpdated not persisting correctly with Mongo DB
1 participant