evolution of database access technologies in java-based software projects

24
Evolu&on of database access technologies in Java-based so6ware projects Loup Meurice Anthony Cleve Csaba Nagy University of Namur, Belgium h?p://informa&que.umons.ac.be/genlog/projects/disse EOSESE 2015 — Lille, France, 3 December 2015 Tom Mens Mathieu Goeminne Alexandre Decan University of Mons, Belgium

Upload: tom-mens

Post on 08-Jan-2017

301 views

Category:

Science


0 download

TRANSCRIPT

Page 1: Evolution of database access technologies in Java-based software projects

Evolu&onofdatabaseaccesstechnologiesinJava-basedso6wareprojectsLoupMeuriceAnthonyCleveCsabaNagy

UniversityofNamur,Belgium

h?p://informa&que.umons.ac.be/genlog/projects/disse

EOSESE2015—Lille,France,3December2015

TomMensMathieuGoeminneAlexandreDecan

UniversityofMons,Belgium

Page 2: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

• Context:InteruniversityFNRS-fundedresearchprojectbetweenUniversitédeMonsandUniversitédeNamur

• Focus:Empiricalanalysisofco-evolu&onbetweenprogramcodeanddatabase(schema)indata-intensiveso6waresystems

• Goal:Providebe?ersupportforsuchco-evolu&ontoso6waredevelopersandprojectmanagers

• Thispresenta&on:Studyusageandevolu&onofrela&onaldatabaseaccess(RDBA)technologiesforopensourceJavasystems

Data-IntensiveSo6wareSystemEvolu&on

Page 3: Evolution of database access technologies in Java-based software projects

Focus

3

•  JavaRDBAtechnologies

Page 4: Evolution of database access technologies in Java-based software projects

4

Focus

•  JavaRDBAtechnologies

Page 5: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015 5

The mapping can take many different forms, as illustrated in Figure 2. The first example showsthe use of Hibernate configuration files (i.e., .hbm.xml). The second example illustrates theuse of Java annotations based on JPA, the standard API in Java for ORM and data persistencemanagement. Such a mapping may allow direct operations on objects, attributes and relationshipsinstead of tables and columns. This is commonly referred as the active record pattern.

Some ORM libraries also provide SQL-inspired languages that allow to write SQL-like queriesusing the mappings defined before. The third example in Figure 2 illustrates the Hibernate QueryLanguage (HQL), and the fourth example uses the Java Persistence Query Language (JPQL), aplatform-independent object-oriented query language which is defined as part of the JPA specifi-cation.

Example of using Hibernate configuration files:

1 < h i b e r n a t e �mapping>2 < c l a s s name=" Customer " t a b l e =" AppCustomers ">3 < i d name=" i d " t y p e =" i n t " column=" i d " / >4 < p r o p e r t y name=" name " column=" name " t y p e =" S t r i n g " / >5 < / c l a s s >6 < / h i b e r n a t e �mapping>

Example of using JPA annotations:

1 @Enti ty2 @Table ( name=" AppCustomers " )3 p u b l i c c l a s s Customer {4 @Id5 p r i v a t e i n t i d ;6 S t r i n g name ;7 [ . . . ]8 }

Example of using Hibernate Query Language (HQL):

1 p u b l i c L i s t <Customer > f i n d A l l C u s t o m e r s ( ) {2 S t r i n g h q l = " s e l e c t c from Customer c " ;3 re turn e x e c u t e Q u e r y ( h q l ) ;4 }5 p u b l i c L i s t e x e c u t e Q u e r y ( S t r i n g h q l ) {6 re turn s e s s i o n . c r e a t e Q u e r y ( h q l ) . l i s t ( ) ;7 }8 p u b l i c Customer f i n d C u s t o m e r ( I n t e g e r i d ) {9 re turn ( Customer ) s e s s i o n . g e t ( Customer . c l a s s , i d ) ;

10 }

Example of direct object manipulation using ActiveJDBC:

1 L i s t <Customer > c u s t o m e r s = Customer . where ( " name = ’ John Doe ’ " ) ;2 Customer john = c u s t o m e r s . g e t ( 0 ) ;3 j ohn . setName ( " John Smith " ) ;4 j ohn . s a v e I t ( ) ;

Figure 2: Four examples of Java ORM usage.

6

The mapping can take many different forms, as illustrated in Figure 2. The first example showsthe use of Hibernate configuration files (i.e., .hbm.xml). The second example illustrates theuse of Java annotations based on JPA, the standard API in Java for ORM and data persistencemanagement. Such a mapping may allow direct operations on objects, attributes and relationshipsinstead of tables and columns. This is commonly referred as the active record pattern.

Some ORM libraries also provide SQL-inspired languages that allow to write SQL-like queriesusing the mappings defined before. The third example in Figure 2 illustrates the Hibernate QueryLanguage (HQL), and the fourth example uses the Java Persistence Query Language (JPQL), aplatform-independent object-oriented query language which is defined as part of the JPA specifi-cation.

Example of using Hibernate configuration files:

1 < h i b e r n a t e �mapping>2 < c l a s s name=" Customer " t a b l e =" AppCustomers ">3 < i d name=" i d " t y p e =" i n t " column=" i d " / >4 < p r o p e r t y name=" name " column=" name " t y p e =" S t r i n g " / >5 < / c l a s s >6 < / h i b e r n a t e �mapping>

Example of using JPA annotations:

1 @Enti ty2 @Table ( name=" AppCustomers " )3 p u b l i c c l a s s Customer {4 @Id5 p r i v a t e i n t i d ;6 S t r i n g name ;7 [ . . . ]8 }

Example of using Hibernate Query Language (HQL):

1 p u b l i c L i s t <Customer > f i n d A l l C u s t o m e r s ( ) {2 S t r i n g h q l = " s e l e c t c from Customer c " ;3 re turn e x e c u t e Q u e r y ( h q l ) ;4 }5 p u b l i c L i s t e x e c u t e Q u e r y ( S t r i n g h q l ) {6 re turn s e s s i o n . c r e a t e Q u e r y ( h q l ) . l i s t ( ) ;7 }8 p u b l i c Customer f i n d C u s t o m e r ( I n t e g e r i d ) {9 re turn ( Customer ) s e s s i o n . g e t ( Customer . c l a s s , i d ) ;

10 }

Example of direct object manipulation using ActiveJDBC:

1 L i s t <Customer > c u s t o m e r s = Customer . where ( " name = ’ John Doe ’ " ) ;2 Customer john = c u s t o m e r s . g e t ( 0 ) ;3 j ohn . setName ( " John Smith " ) ;4 j ohn . s a v e I t ( ) ;

Figure 2: Four examples of Java ORM usage.

6

Focus

•  JavaRDBAtechnologies

Page 6: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Focus

•  ORMspromisetoreducethe“object-rela&onalimpedancemismatch”

•  Butdotheyreally?•  Whataretherisksandadvantagesofusingapar&culartechnology?

•  HowdoprojectsusingORMevolveover&me?•  Howaremul&pleORMtechnologiesusedtogether?Dotheytendtocomplementorsubs&tuteoneanother?

•  HowarethecodeandDBschemakeptsynchronised?

Page 7: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Coarse-grainedanalysis

•  EmpiricalstudyonopensourceJavaprojects–  13,307s&llac&veJavaprojectsextractedfromGitHubJavaCorpus[Allamanis&Su?on—MSR2013]

–  4,503ofthemusedanRDBAtechnology–  2,818projectsusedJDBC,JPA,SpringorHibernate

Page 8: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Coarse-grainedanalysis

•  Evolu&onofRDBAtechnologyusage–  Rela&veshareofeachofthe4consideredtechnologies

•  JDBCremainsmostprominent,butdecreasingsharesince2006•  Sinceitsintroduc&on,shareofJPAcon&nuestoincrease

Page 9: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Coarse-grainedanalysis

•  Co-occurrenceofRDBAtechnologies– ManyprojectswithJPA,HibernateorSpringalsousedirectJDBCaccess

–  38%ofallprojectsuseatleast2technologies–  Projectsusingmul&pletechnologiestendtousethemsimultaneously(>80%)

JPASpring JDBC

Hibernate284

167 1239

6086

124

133

139

16

76

61

64143

46

180

Hibernateo8enco-occurswithJPA(77%)andJDBC(61%)

Page 10: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Coarse-grainedanalysis

•  IntroducingandremovalofRDBAtechnologies–  Technologiesareintroducedearlyinprojectlife&me–  Technologiesdisappearfasterinsmallthaninlargeprojects

Introduc&on&me Removal&me

Page 11: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Coarse-grainedanalysis

•  IntroducingandremovalofRDBAtechnologies– Newtechnosareintroducedmoreo6eninlargeprojects–  JDBCisnotfollowedfrequentlybyothertechnos– Hibernateisfrequentlyfollowedbyanothertechno

“Survivalcurve”

Probabilitythatatechnoremainsthelastlyintroducedone

smallprojects

largeprojects

Page 12: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

•  Researchques&ons•  HowdodevelopersdecidetointroducenewRDBAtechnologies?

•  Howandwherearepar&culartechnologiesusedinthesourcecode?

•  Aredatabaseschemaelementsaccessedbydifferenttechnologies?

•  Focuson3par&cularJavaprojects

Page 13: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

Distribu&onofaccessedtablesacrosstechnologies

•  HibernatecomplementsJDBC

•  JPAreplacesHibernate&JDBC

•  Tablesaccessedbyseveraltechnologies

Page 14: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

•  MajorityoftablesaccessedbyHibernate

•  AfewtablesaccessedviaJDBC

•  SometablesaccessedbybothHibernate&JDBC

Distribu&onofaccessedtablesacrosstechnologies

Page 15: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

•  JPAonlyusedtechnology

•  Highnumberofunaccessedtables

Distribu&onofaccessedtablesacrosstechnologies

Page 16: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

UnIlintroducIonofJPA:majorityoffilesaccessingDBviaHibernate.

A8erintroducIonofJPA:progressivedecreaseof#filesaccessingDBviaHibernateandJDBC

Distribu&onoffilesaccessingthedatabase

Page 17: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

Hibernateremainsmaintechnology

JDBCandHibernatetogetherinsomefiles

èbadcodingprac&ces?

Distribu&onoffilesaccessingthedatabase

Page 18: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

Stabiliza&onin2013

Distribu&onoffilesaccessingthedatabase

Page 19: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

•  MajorityofHibernatemappingsreplacedbyJPAmappings.

•  BigpartofDBschemaremainsunmapped.

•  SmallsetoftablescontainbothHibernateandJPAmappings.

Distribu&onofmappedtablesacrosstechnologies

Page 20: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

Hibernatemaintechnology

èmajorityoftables

withHibernatemapping

Distribu&onofmappedtablesacrosstechnologies

Page 21: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

Fine-grainedanalysis

JPAonlyusedtechnology

è majorityoftableswithJPAmapping

Distribu&onofmappedtablesacrosstechnologies

Page 22: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

•  Coarse-grainedanalysis–  Technologiestendtobeusedincombina&on(especiallyforlargeprojects)–  Sometechnologies(Hibernate)tendtogetreplacedmoreo6en–  JPAcon&nuestoincreaseitsmarketshare–  InspiteofORMpromises,“legacy”technologies(JDBC)remainheavilyused–  Newlyintroducedtechnologiestendto“complement”exis&ngones

•  Fine-grainedanalysis–  Differentprojectswithverydifferentuseoftechnologies–  Sometablescanbeaccessedthroughdifferenttechnologies–  Somesourcecodefileusedmul&pletechnologies–  Sometables/columnsarenotaccessedèmightsuggestthatco-evolu&on

ofschemaandprogramsisnotalwaysatrivialprocess

22

Conclusions

Page 23: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

•  Broadenthescope–  Non-rela&onaldatabasetechnologies–  Closedsourceprojects–  Non-Javaprojects

•  Studysocialaspects–  Differentteamsfordifferenttechnologies?Differentteamsforcodeversusdatabase?

•  Provideautomatedtoolsupport–  Decisionalsupporttoprojectmanagerstochooseanewtechnoandtodecideif,whenandhowtointroduceit

–  Visualisa&onsupportforthecode/databaseco-evolu&onandthetechnologyco-occurrences

23

FutureWork

Page 24: Evolution of database access technologies in Java-based software projects

EOSESE–Lille,France,3December2015

•  LMeurice,MGoeminne,TMens,CNagy,ADecan,ACleve.AnalyzingtheevoluIonofdatabaseusageindata-intensiveso8waresystems.[Toappearinbookchapter]

•  MGoeminne,TMens.TowardsasurvivalanalysisofdatabaseframeworkusageinJavaprojects.ICSME2015ERAtrack

•  MGoeminne,ADecan,TMens.Co-evolvingcode-relatedanddatabase-relatedchangesinadata-intensiveso8waresystem.CSMR-WCRE2014ERAtrack

•  LMeurice,ACleve.DAHLIA:AvisualanalyzerofdatabaseschemaevoluIon.CSMR-WCRE2014ToolDemo

•  ACleve,MGobert,LMeurice,JMaes,JWeber.UnderstandingdatabaseschemaevoluIon:Acasestudy.ScienceofComputerProgramming(2013)

•  ACleve,TMens,J-LHainaut.Data-intensivesystemevoluIon.IEEEComputer43(8):110-112(2010)

24

References