This talk was presented by Tom Mens and Loup Meurice at the EvoLille'15 European Open Symposium on Empirical Software Engineering (December 2015). We report on the evolution of open source Java projects relying on relational database technologies. We empirically analysed how the use of Java database access technologies evolves over time. We carried out a coarse-grained source-code analysis over several thousands of Java projects on GitHub, and complemented this by a fine-grained longitudinal analysis of the co-evolution between database schema changes and source code changes within three large Java projects (OSCAR, OpenEMR and BroadLeaf). The presented results are a first step towards a recommendation system supporting developers in writing database-centered code. The research was part of an interuniversity research project between University of Mons and University of Namur, financed by the F.R.S.-FNRS, Belgium.
5. EOSESE – Lille, France, 3 December 2015 5
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 < id name=" id " type =" i n t " column=" id " / >
4 < p r o p e r t y name="name" column="name" type =" 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 @Entity
2 @Table ( name=" AppCustomers " )
3 public c l a s s Customer {
4 @Id
5 private i n t id ;
6 S t r i n g name ;
7 [ . . . ]
8 }
Example of using Hibernate Query Language (HQL):
1 public List <Customer > findAllCustomers ( ) {
2 S t r i n g hql = " s e l e c t c from Customer c " ;
3 return executeQuery ( hql ) ;
4 }
5 public L i s t executeQuery ( S t r i n g hql ) {
6 return s e s s i o n . createQuery ( hql ) . l i s t ( ) ;
7 }
8 public Customer findCustomer ( I n t e g e r id ) {
9 return ( Customer ) s e s s i o n . get ( Customer . class , id ) ;
10 }
Example of direct object manipulation using ActiveJDBC:
1 List <Customer > customers = Customer . where ( "name = ’ John Doe ’ " ) ;
2 Customer john = customers . get ( 0 ) ;
3 john . setName ( " John Smith " ) ;
4 john . 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 shows
the use of Hibernate configuration files (i.e., .hbm.xml). The second example illustrates the
use of Java annotations based on JPA, the standard API in Java for ORM and data persistence
management. Such a mapping may allow direct operations on objects, attributes and relationships
instead 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 queries
using the mappings defined before. The third example in Figure 2 illustrates the Hibernate Query
Language (HQL), and the fourth example uses the Java Persistence Query Language (JPQL), a
platform-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 < id name=" id " type =" i n t " column=" id " / >
4 < p r o p e r t y name="name" column="name" type =" 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 @Entity
2 @Table ( name=" AppCustomers " )
3 public c l a s s Customer {
4 @Id
5 private i n t id ;
6 S t r i n g name ;
7 [ . . . ]
8 }
Example of using Hibernate Query Language (HQL):
1 public List <Customer > findAllCustomers ( ) {
2 S t r i n g hql = " s e l e c t c from Customer c " ;
3 return executeQuery ( hql ) ;
4 }
5 public L i s t executeQuery ( S t r i n g hql ) {
6 return s e s s i o n . createQuery ( hql ) . l i s t ( ) ;
7 }
8 public Customer findCustomer ( I n t e g e r id ) {
9 return ( Customer ) s e s s i o n . get ( Customer . class , id ) ;
10 }
Focus
• Java RDBA technologies
22. EOSESE – Lille, France, 3 December 2015
• Coarse-grained analysis
– Technologies tend to be used in combina&on (especially for large projects)
– Some technologies (Hibernate) tend to get replaced more o6en
– JPA con&nues to increase its market share
– In spite of ORM promises, “legacy” technologies (JDBC) remain heavily used
– Newly introduced technologies tend to “complement” exis&ng ones
• Fine-grained analysis
– Different projects with very different use of technologies
– Some tables can be accessed through different technologies
– Some source code file used mul&ple technologies
– Some tables/columns are not accessed è might suggest that co-evolu&on
of schema and programs is not always a trivial process
22
Conclusions
23. EOSESE – Lille, France, 3 December 2015
• Broaden the scope
– Non-rela&onal database technologies
– Closed source projects
– Non-Java projects
• Study social aspects
– Different teams for different technologies?
Different teams for code versus database?
• Provide automated tool support
– Decisional support to project managers to choose a new techno
and to decide if, when and how to introduce it
– Visualisa&on support for the code/database co-evolu&on and the
technology co-occurrences
23
Future Work