Skip to content

Transaction scope behavior seems to differ from the docs #2669

Answered by B4nan
dbettini asked this question in Q&A
Discussion options

You must be logged in to vote

I can't use find since only findOne seems to have that option in v4, so I went with a query builder approach.

I'd say upgrade to v5, no reason to be worried at this stage as its pretty much done, RC is out :]

Now, my understanding from the documentation was that I need to use the em instance provided in the callback to actually make queries as part of that transaction,

That is no longer true, the whole callback is executed in a new transaction scope, so you can use the global EM too and it will pick the right tx context automatically. So you can use the repositories from DI.

Note that there is no such thing as "flushing a repository". You always flush the underlying EM, and you always…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by dbettini
Comment options

You must be logged in to vote
7 replies
@dbettini
Comment options

@B4nan
Comment options

@dbettini
Comment options

@B4nan
Comment options

@dbettini
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2668 on January 24, 2022 15:12.