If a method of service is marked as @Transactional
with propagation nested, and inside it there are many calls to other @Transactional
methods, each one of these methods will use its own session? It should represent many connections to db for just one method call no?
Asked
Active
Viewed 626 times
1

Harshal Patil
- 6,659
- 8
- 41
- 57

Ignasi
- 5,887
- 7
- 45
- 81
1 Answers
2
It looks like PROPAGATION_REQUIRED
is better option for your purpose. From its javadoc:
Support a current transaction; create a new one if none exists.

Harshal Patil
- 6,659
- 8
- 41
- 57
-
Sorry maybe I wasn't clear but it's just curiosity, I always use default propagation of Spring, so I always have only on transaction (the outer one). But the q – Ignasi Nov 27 '14 at 17:39
-
yes so using propagation you can give multiple recursive calls to the transaction you no need to worry for that :) – Harshal Patil Nov 27 '14 at 17:42
-
yes but my question was about sessions, what about this recursive calls getting sessions? it means that calling one method it could use N connections to db? – Ignasi Nov 27 '14 at 20:22
-
No only one conection at a time – Harshal Patil Nov 28 '14 at 04:34
-
It's explained in some place? Im unable to find it :S – Ignasi Dec 09 '14 at 12:20
-
refer this link http://stackoverflow.com/questions/10740021/transactionalpropagation-propagation-required – Harshal Patil Dec 09 '14 at 12:31