Prior to this change they made an explicit transaction if one was needed, and this would always use the Main DataSource.
With this change, when there is no transaction assigned to the query and no active transaction, then the find future query will use the ReadOnly DataSource if it has been configured (e.g. ReadOnly DataSource might point to a read replica database instance).
The test was using field access??? when that isn't valid unless we specifically turn on enhancement to support that.
Using proper method access though stops the test from failing.
So we can no longer dynamically change the Clock being used and instead for testing purposes need to create the Database with a test clock instance as needed.
Refer to the ExtendedServerTest for an example
* ADD: Testcase for showing nested transaction with batch-mode not flushing batch on commit
* Update test only - TestNestedTransaction.test_txn_nestedWithInnerBatch()
Update the test to show that we desire the nested transaction changes to be "visible" after a commit regardless of flushOnQuery etc
* #3564 Fix for nested transaction with batch-mode does not flush
- Adds flush() into ScopeTrans.commitTransaction()
- Related fixes in DefaultServer execute() and executeCall() where it was performing extra unnecessary nesting on PersistenceException
* Touch
---------
Co-authored-by: Jonas Pöhler <jonas.poehler@foconis.de>
As HelpScopeTrans isn't in an exported package it's use fails with an error in module path. This adds AOPTransactionScope in the exported package io.ebean.plugin and moves the required methods from SpiEbeanServer to SpiServer to support this move.
This also requires an associate change in ebean-agent to support this feature which will be in ebean-agent 14.9.0.
Internally in CQueryBuilder only use query.setSelectId(); for findCount when the entity bean has a @Id property [which it doesn't strictly need and likely won't have for view based entities]
* #3552 Column alias required for SQL Server + findCount + distinct
- Modifies CQueryBuilder with the main fix which is to use the database platform selectCountWithColumnAlias for all distinct queries [and later disable it for single column case]
- Modifies SqlTreeBuilder because we need to NOT use the column alias for the count distinct SINGLE COLUMN case. So change here to:
- build the root SqlTreeNode first as part of constructor
- use rootNode.isSingleProperty() to NOT use column alias for the single column case
- Hence need to initialise DefaultDbSqlContext AFTER the root SqlTreeNode
- Modifies DefaultDbSqlContext with no effective change, just columnIndex++ ONLY when we are actually using column alias
- Modifies H2Platform to also use selectCountWithColumnAlias true
* #3552 selectCountWithColumnAlias true for MariaDB and MySql
Plus fix TestRowCount for Oracle platform