Can Annotated Tractional attributes be changed in Spring through Java reflection?
-
25-10-2019 - |
Question
I would like to change the Transaction attributes (especially the TransactionManager ) during runtime via reflection. Is this possible?
eg: @Transactional('ChangeMe')
Solution
As fare as I know, Java has no function to modify the annotations at runtime.
But you can use programmatic transaction management, instead of the annotation.
On the other hand you can try to modify springs declarative transaction management, to enable and disable the transactions by some List or Map, but not by reflection.
Additional references:
- How to add Annotations at Runtime to a java class method using Javassist? (they modify the class, but this mean creating a new one -- that is how I understand it)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow