Skip to content
Back to skills

Doctrine Transactions

ASecurity

Handle Doctrine transactions (ORM 3 wrapInTransaction), optimistic/pessimistic locking, flush strategies, and transaction boundaries

  • 221 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added August 31, 2026
developmentgoshellbashrailsapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 6, 2026

npx -y skills add dev-toolings/superpowers-symfony --skill doctrine-transactions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Doctrine Transactions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Doctrine Transactions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dev-toolings-doctrine-transactions/badge)](https://www.skillsdirectory.com/skills/dev-toolings-doctrine-transactions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: doctrine-transactions
description: Handle Doctrine transactions (ORM 3 wrapInTransaction), optimistic/pessimistic locking, flush strategies, and transaction boundaries
capabilities: [read, search, edit, shell]
tags: [doctrine]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# Doctrine Transactions (Symfony)

## Use when
- Several writes must succeed or fail together.
- Two users or workers can edit the same row concurrently.
- Deciding where to flush and who owns the transaction boundary.
- Recovering after a failed flush, a constraint violation, or a lost connection.

## Default workflow
1. Place the transaction boundary in the service layer, not in the controller.
2. Group related changes and flush once, inside `wrapInTransaction()`.
3. Pick the concurrency strategy: `#[ORM\Version]` optimistic locking for edits, `PESSIMISTIC_WRITE` for short critical sections.
4. Handle `OptimisticLockException` and constraint violations explicitly.
5. After a rollback, clear the EntityManager and re-fetch what you still need.

## Guardrails
- On ORM 3, `EntityManager::transactional()` is gone: use `wrapInTransaction()`.
- Outside an explicit transaction each flush commits on its own, so avoid several flushes per operation.
- Keep transactions and pessimistic locks short; no HTTP calls or mail inside.
- Do not reuse entities from a failed unit of work.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- Transaction boundaries with a single flush per operation.
- The locking strategy chosen per entity, and how conflicts reach the user.
- Rollback handling and the state of the EntityManager after it.

## References
- `reference.md`

Files in this skill

  • SKILL.md1.1 KB
  • reference.md8.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…