An Empirical Study on the Practice of
Maintaining Object-Relational Mapping
Code in Java Systems
1
Mohamed Nasser, Parminder Flora
Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Jinqiu Yang Michael W. Godfrey
Databases are essential in modern
large-scale software systems
2
Database
3
Object-Relational Mapping (ORM)
eliminates the gap between objects
and SQL
Database
• Less boilerplate code
• Object-DB translations are done
automatically
Java
Classes
Benefits over raw SQLs
ORM
Much less code and shorter
development time
ORM provides another layer of
abstraction
4
ORM
Database mapping code
@Table(name = “user”)
Performance configuration
query.cache()
ORM query code
User u = q.getSingleResult();
5
ORM is not a silver bullet
Using ORM comes with some hidden
costs…
We have been working on
helping developers improve
ORM code for the past few
years
Developers are often not aware of
database access
Wow! I don’t
need to worry
about DB code!
ORM code with
performance anti-patterns
6
Bad system
performance
The performance impact can be
SIGNIFICANT (ICSE 2014)!
ORM is hard to configure
7
Hundreds of ORM
performance-related
configuration
Un-optimal ORM configuration is common
and causes significantly performance
problem (TSE 2016)!
Bad system
Performance if
configured incorrectly
Studying maintenance activities of
Java ORM code
8
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
Studied Java systems
Large open-source
e-commence system
Enterprise system
9
Portal Content management system
Studying maintenance activities of
Java ORM code
10
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
Lack of bug detection tool support for
Java ORM
11
Coverity PMD Google error-prone
Facebook InferFindBugs
More than 67% of Java developers use ORM, but
there is limited tooling support (ICSE SEIP 2016)
Studying maintenance activities of
Java ORM code
12
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
No! There is
limited tooling
support
Studying maintenance activities of
Java ORM code
13
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
No! There is
limited tooling
support
ORM configurations are rarely tuned
14
Most ORM code changes are related to
ORM queries (35%) and ORM database
mapping code (55%)
ORM performance configurations are
rarely tuned (less than 10%)
Studying maintenance activities of
Java ORM code
15
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
No! There is
limited tooling
support
No! ORM
configurations
are rarely tuned
Studying maintenance activities of
Java ORM code
16
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
No! There is
limited tooling
support
No! ORM
configurations
are rarely tuned
ORM code changes are more
scattered
17
0
2
4
6
8
10
12
14
ORM
non-ORM
Medianmodifiedfilesinacommit
Such high change scatteredness may be
caused by ORM’s inability to completely
abstract DB accesses
Studying maintenance activities of
Java ORM code
18
Expect: ORM-related
changes are localized
Expect: Frequently
tuning configurations
Expect: Tooling
support due to ORM
popularity
No! There is
limited tooling
support
No! ORM
configurations
are rarely tuned
No! ORM code
changes are
more scattered
19
20
21
22
23
24
25
26
27
Tse-Hsun (Peter) Chen tsehsun@cs.queensu.ca

MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

  • 1.
    An Empirical Studyon the Practice of Maintaining Object-Relational Mapping Code in Java Systems 1 Mohamed Nasser, Parminder Flora Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Jinqiu Yang Michael W. Godfrey
  • 2.
    Databases are essentialin modern large-scale software systems 2 Database
  • 3.
    3 Object-Relational Mapping (ORM) eliminatesthe gap between objects and SQL Database • Less boilerplate code • Object-DB translations are done automatically Java Classes Benefits over raw SQLs ORM Much less code and shorter development time
  • 4.
    ORM provides anotherlayer of abstraction 4 ORM Database mapping code @Table(name = “user”) Performance configuration query.cache() ORM query code User u = q.getSingleResult();
  • 5.
    5 ORM is nota silver bullet Using ORM comes with some hidden costs… We have been working on helping developers improve ORM code for the past few years
  • 6.
    Developers are oftennot aware of database access Wow! I don’t need to worry about DB code! ORM code with performance anti-patterns 6 Bad system performance The performance impact can be SIGNIFICANT (ICSE 2014)!
  • 7.
    ORM is hardto configure 7 Hundreds of ORM performance-related configuration Un-optimal ORM configuration is common and causes significantly performance problem (TSE 2016)! Bad system Performance if configured incorrectly
  • 8.
    Studying maintenance activitiesof Java ORM code 8 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity
  • 9.
    Studied Java systems Largeopen-source e-commence system Enterprise system 9 Portal Content management system
  • 10.
    Studying maintenance activitiesof Java ORM code 10 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity
  • 11.
    Lack of bugdetection tool support for Java ORM 11 Coverity PMD Google error-prone Facebook InferFindBugs More than 67% of Java developers use ORM, but there is limited tooling support (ICSE SEIP 2016)
  • 12.
    Studying maintenance activitiesof Java ORM code 12 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity No! There is limited tooling support
  • 13.
    Studying maintenance activitiesof Java ORM code 13 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity No! There is limited tooling support
  • 14.
    ORM configurations arerarely tuned 14 Most ORM code changes are related to ORM queries (35%) and ORM database mapping code (55%) ORM performance configurations are rarely tuned (less than 10%)
  • 15.
    Studying maintenance activitiesof Java ORM code 15 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity No! There is limited tooling support No! ORM configurations are rarely tuned
  • 16.
    Studying maintenance activitiesof Java ORM code 16 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity No! There is limited tooling support No! ORM configurations are rarely tuned
  • 17.
    ORM code changesare more scattered 17 0 2 4 6 8 10 12 14 ORM non-ORM Medianmodifiedfilesinacommit Such high change scatteredness may be caused by ORM’s inability to completely abstract DB accesses
  • 18.
    Studying maintenance activitiesof Java ORM code 18 Expect: ORM-related changes are localized Expect: Frequently tuning configurations Expect: Tooling support due to ORM popularity No! There is limited tooling support No! ORM configurations are rarely tuned No! ORM code changes are more scattered
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
    27 Tse-Hsun (Peter) Chentsehsun@cs.queensu.ca