The issue is about all DB connections being drained from the CP, from the same call with the final error message of:
"Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/ActiveDS"
Debugging the issue in Intellij shows that for this simple case of reading from a Code table (static data), causes a save and flush, which causes dirty-checking. For some reason onFlushDirty() is triggered in a loop, for as many connections as the pool contains. See image below.
I believe its the doInHibernate() operation which triggers this as, flush mode is Auto. But this issue is far beyound what I know about Hibernate, hence I wanted a quick fix with a query with READ_ONLY mode.
But, I really dont know what the root cause is, as the log output for each case is a 10 leveled exception of 1000 log lines, times the number of connections in the pool.
This code has not been changed, for 10+ years, but it seems the error has been masked by another error that is just eaten up by a try-catch and dealt with on its own. Hence undetected.
Here is a beginning stack trace image from Intellij, it also shows the loop count:
