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

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

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.

Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}