You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (Jira)" <ji...@apache.org> on 2026/06/07 17:19:00 UTC

[jira] [Updated] (CAY-2954) Don't wrap selecting queries in transactions

     [ https://issues.apache.org/jira/browse/CAY-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik updated CAY-2954:
---------------------------------
    Description: 
Cayenne surrounds every DB interaction with a transaction. This doesn't make sense for single select operations (the only case where it would is long running externally managed transactions, where selects should see uncommitted DB state produced by prior changes; though should be handled at the DataSource level).

So let's bypass implicit transactions when we can. Since Cayenne has no idea whether the query requires a tx or not, the indicator should be provided by the query itself (\{{q.getMetadata().isReadOnly()}}). Most queries know whether they are "read-only" or not. For those that don't (such as ProcedureQuery) it will default to "false".

h2. Other considerations

* Currently, we force "autoCommit=false" on every connection. Show we keep doing that?
* Transaction listeners should no long receive begin/commit/rollback events. That's a breaking change, but also looks like the correct thing to do.

 

  was:
Cayenne surrounds every DB interaction with a transaction. This doesn't make sense for single select operations (the only case where it would is long running externally managed transactions, where selects should see uncommitted DB state produced by prior changes; though should be handled at the DataSource level).

So let's bypass implicit transactions when we can. Since Cayenne has no idea whether the query requires a tx or not, the indicator should be provided by the query itself (\{{q.getMetadata().isReadOnly()}}). Most queries know whether they are "read-only" or not. For those that don't (such as {color:#000000}ProcedureQuery) it will default to "false".{color}

 


> Don't wrap selecting queries in transactions
> --------------------------------------------
>
>                 Key: CAY-2954
>                 URL: https://issues.apache.org/jira/browse/CAY-2954
>             Project: Cayenne
>          Issue Type: Task
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>            Priority: Major
>
> Cayenne surrounds every DB interaction with a transaction. This doesn't make sense for single select operations (the only case where it would is long running externally managed transactions, where selects should see uncommitted DB state produced by prior changes; though should be handled at the DataSource level).
> So let's bypass implicit transactions when we can. Since Cayenne has no idea whether the query requires a tx or not, the indicator should be provided by the query itself (\{{q.getMetadata().isReadOnly()}}). Most queries know whether they are "read-only" or not. For those that don't (such as ProcedureQuery) it will default to "false".
> h2. Other considerations
> * Currently, we force "autoCommit=false" on every connection. Show we keep doing that?
> * Transaction listeners should no long receive begin/commit/rollback events. That's a breaking change, but also looks like the correct thing to do.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)