It Will Never Work in Theory

Maintaining Java ORM Code

Posted Apr 26, 2016 by Greg Wilson

| Maintenance |

Tse-Hsun Chen, Weiyi Shang, Jinqiu Yang, Ahmed E. Hassan, and Michael W. Godfrey: "An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems". MSR'16, May 2016,

From the abstract:

Despite the advantages of using ORM [object-relational mapping] frameworks, we observe several difficulties in maintaining ORM code (i.e., code that makes use of ORM frameworks) when cooperating with our industrial partner. After conducting studies on other open source systems, we find that such difficulties are common in other Java systems. Our study finds that i) ORM cannot completely encapsulate database accesses in objects or abstract the underlying database technology, thus making ORM code changes more scattered; ii) ORM code changes are more frequent than regular code, but there is a lack of tools that help developers verify ORM code at compilation time; iii) changes to ORM code are more commonly due to performance or security reasons; however, traditional static code analyzers need to be extended to capture the peculiarities of ORM code in order to detect such problems. Our study highlights the hidden maintenance costs of using ORM frameworks, and provides some initial insights about potential approaches to help maintain ORM code. Future studies should carefully examine ORM code, in particular given the rising use of ORM in modern software systems.

I wasn't surprised to find that ORMs can't completely encapsulate database access, but I was surprised to learn that the result is scattered code changes. I was even more surprised to find that changes to ORM code are more common than changes to "regular" code, but that's one of the reasons to read research: to find out where personal experience is atypical of general practice. And I hope the authors of various IDEs take the third point to heart: PyCharm's ability to debug Django templates saved me days of tedious debugging (at least), and similar support for debugging ORM code might have saved me even more.

Comments powered by Disqus