codeconsole commented on PR #16214: URL: https://github.com/apache/grails-core/pull/16214#issuecomment-5744036244
@jdaugherty you're right — the rule is datastore-wide, MongoDB was just the one that broke it. Reworded in `95c0d27d66`. Here is what each in-tree datastore did on a read-only commit: | Datastore | Before | After | |---|---|---| | Hibernate 5 / 7 | no flush — `GrailsHibernateTransactionManager.doBegin` sets `FlushMode.MANUAL` | unchanged | | MongoDB | **flushed** — `MongoTransaction.commit()` / `SessionOnlyTransaction.commit()` flush unconditionally | no flush | | Neo4j | no flush — `Neo4jTransaction.commit()` commits the Bolt transaction only, and `readOnly` already selects `AccessMode.READ` | unchanged | | Simple map | no flush — `MockTransaction.commit()` does nothing | unchanged | `DatastoreTransactionManager.doCommit` already skipped its own flush for a read-only transaction, so the only datastore where anything was still written was MongoDB, through the transaction's own commit. The docs now lead with the rule rather than the datastore: - Upgrade guide: *A read-only transaction no longer flushes the session* — states it for every GORM datastore, names Hibernate, Neo4j and the simple map datastore as already behaving that way, and keeps the MongoDB specifics (queued write, `COMMIT` flush mode, discarded on session close, `save(flush: true)` or a read-write transaction) in a continuation paragraph. - What's New: retitled *Read-Only Transactions Do Not Flush the Session*, with MongoDB as the exception being fixed. - The upgrade note also points datastore implementations outside this repository at the change: `SessionOnlyTransaction` gives them the behaviour for free, and a datastore with its own `Transaction` can honour `readOnly` by overriding `AbstractSession.beginTransactionInternal(TransactionDefinition)`, which now receives the definition instead of discarding it. - The GORM for MongoDB guide's *Read-Only Transactions* section now says this is how GORM's other datastores behave rather than singling out Hibernate. Rebuilt `:grails-data-mongodb-docs:asciidoctor` (anchor and links still resolve). I have not built `grails-doc`; the multi-paragraph bullet uses the same `+` continuation as existing entries in `upgrading80x.adoc`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
