domaframework / doma

DAO oriented database mapping framework for Java
https://doma.readthedocs.io/
Apache License 2.0
438 stars 69 forks source link

Feature Request: Use LocalTransaction only when necessary #1125

Closed orekyuu closed 2 months ago

orekyuu commented 2 months ago

Description Currently, when using LocalTransactionDataSource, queries can only be executed within a transaction. If a query is executed outside of a transaction, it throws a LocalTransactionNotYetBegunException. https://github.com/domaframework/doma/blob/master/doma-core/src/main/java/org/seasar/doma/jdbc/tx/LocalTransactionDataSource.java#L92

Is there a way to avoid using transactions except where necessary?

Implementation ideas I would like to have the option to either throw an exception or delegate to the dataSource when outside of a transaction.

nakamura-to commented 2 months ago

Thanks for your feedback.

Does #1126 meet your needs? By the way, could you please tell me why you want this feature?

orekyuu commented 2 months ago

Yes, #1126 is exactly what I am looking for. For example, when issuing only select queries such as an API that returns user information, I believe it is unnecessary to use transactions.