Hibernate? …but it’s still summer!

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s