This looks close to what I need. It was suggested by ChatGPT.
import org.apache.cayenne.tx.BaseTransaction;
import org.apache.cayenne.tx.Transaction;
import java.sql.Connection;
runtime.performInTransaction(() -> {
BaseTransaction tx = (BaseTransaction)
BaseTransaction.getThreadTransaction();
if (tx != null) {
// Iterate over all connections (key = DataNode name)
tx.getConnections().forEach((nodeName, connection) -> {
System.out.println("Node: " + nodeName + ", Connection: " +
connection);
});
// Or, if you know the node name:
Connection conn = tx.getConnection("mynode");
// Now you can use the JDBC Connection directly (careful — this
bypasses Cayenne!)
}
return null;
});
>
> On Oct 4, 2025, at 6:20 PM, Andrus Adamchik <[email protected]> wrote:
>
> BaseTransaction.getThreadTransaction()