OpenMRS uses hibernate (the noun – the “open-source object-relational mapping tool.”) to help objects communicate with the database.
Using the Module Maven Archetype gives you the option to add a service layer. When I was setting up my module I said yes to adding a service layer just in case, and didn’t think much about it until a few weeks ago. The reason I decided to implement a MergeConceptsService was that I wanted a query from the openmrs database that wasn’t directly available using the ObsService.
The Module Maven Archetype option to add a service layer gives a module four files that make up the service layer: DAO, HibernateDAO, Service, and ServiceImpl. DAO and Service are interfaces implemented by HibernateDAO and ServiceImpl. The HibernateDAO is home to the sessionFactory, which actually connects to the database. The ServiceImpl will instantiate a DAO, and then the module controller is free to instantiate a Service.
The hibernate mapping file is unnecessary unless you are using hql to change a table.