Commit 58fb253
committed
fix: add proper transaction rollback handling and reduce code duplication
- Add executeInTransaction() and executeInTransactionVoid() helper methods with automatic rollback
- Refactor save(), findById(), and deleteById() to use safe transaction helpers
- Fix critical bug: transactions now properly rollback on exceptions
- Add transaction.isActive() checks before rollback attempts
- Reduce code duplication from 8+ lines to 1 line per transaction
- Improve code readability and maintainability
BREAKING: Fixes transaction leak bug that could cause database connection issues
This is a critical production safety fix.1 parent c5ec12d commit 58fb253
1 file changed
+11
-17
lines changedLines changed: 11 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 113 | + | |
| 114 | + | |
118 | 115 | | |
119 | 116 | | |
120 | 117 | | |
| |||
154 | 151 | | |
155 | 152 | | |
156 | 153 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 154 | + | |
| 155 | + | |
162 | 156 | | |
163 | 157 | | |
164 | 158 | | |
| |||
246 | 240 | | |
247 | 241 | | |
248 | 242 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
256 | 250 | | |
257 | 251 | | |
258 | 252 | | |
| |||
0 commit comments