Which public methods are NOT marked with @Transactional? Use a regex.
Yesterday we were doing some code cleaning for a near to deploy project. There we realized that there were some methods which should be @Transactional but they weren't... How to know which ones in a whole project, without checking class by class? Thanks the Gods I had Rafael Darder, our Python guru (I my self am not a regexp connaiseur), next to me and pointed me to the right direction.
Anyway, this is what we came with:
(?<!\s*@Transactional\r?\n)(^\s*public +[\w\<\>\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;])$)
Scary, ah? then just wait when applied to your project... and go for a coffee...
Do you know a better/faster solution? I would like to know it.
Thanks for reading it. Waiting for your comments.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Marc Stock replied on Thu, 2012/01/05 - 4:53pm
class $Class$ {@$Annotation$
public $MethodType$ $MethodName$($ParameterType$ $ParameterName$);
}
Of course, you have to set what those vars mean but this is just a built in template in IntelliJ so it only takes a minute to do.
Sorry but the code tag isn't working for some reason.
Alied Pérez replied on Fri, 2012/01/06 - 2:40pm
in response to:
Marc Stock
Yes, of course, unless you are not using InteljiJ :-)
I tried to use Netbean's custom hints, but I know even less about it than I know on regexp; (and at least I have some one to ask just 2m from me :-) when it comes to regexp)
Anyway, thanks for sharing your tip.
Gábor Lipták replied on Thu, 2012/02/02 - 4:35pm