Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Which public methods are NOT marked with @Transactional? Use a regex.

DZone's Guide to

Which public methods are NOT marked with @Transactional? Use a regex.

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}