Skip to content

DBAL-947: [GH-634] Transaction object definition #2191

Closed
doctrinebot opened this Issue Jul 21, 2014 · 2 comments

3 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: #634

Message:

To move forward with the Transaction Object, here is an alternative proposal to #571.

This keeps the same basic idea, but now createTransaction() returns a TransactionDefinition object, which is configurable, and has a begin() method that starts the underlying transaction and returns the Transaction object:

$tx = $em->createTransaction()                                 // TransactionDefinition
    ->withIsolationLevel(Connection::TRANSACTION_SERIALIZABLE) // TransactionDefinition
    ->begin();                                                 // Transaction

I think that this implementation checks all the boxes:

  • Clear separation between the Transaction and its Definition
  • Once the Transaction is created, its Definition is set and cannot be changed
  • No risk to forget to call begin(): if you do, you'll deal with a TransactionDefinition and just get a call to undefined method if you try to commit() it. Plus, your IDE will be able to warn you while coding.

And needless to say, we're still keeping 100% BC compatibility.

What do you think?

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-634] was assigned:
#634

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@deeky666 deeky666 added New Feature PR Created and removed Bug labels Jan 6, 2016
@beberlei beberlei was unassigned by deeky666 Jan 6, 2016
@deeky666 deeky666 closed this Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.