The hibernate 4 sessionfactory class is different from the hibernate 3 sessionfactory class. The applicationContext of OpenMRS versions which have to support hibernate 4 can use the new configuration.
ie
Any module building against the right OpenMRS version will get the right hibernate sessionfactory which have the same interface.
There seems to be some differences with the way transactions are handled between the two versions, however the behavior is (should) be equivalent if a JTA is configured. If OpenMRS does not configure a JTA then more research is needed.
Last time we discussed this, the consensus recommendation was:
Our recommendation is that most modules should: (1) increase their
required-version of OpenMRS (i.e. to at least 1.11.3, 1.10.2, 1.9.9) and
(2) start using DbSessionFactory where they used to use SessionFactory.
In some special cases you can take the alternate approach that XForms
did.
Generally speaking, āupgrade to the latest version of your release lineā
should be expected behavior of any implementation that wants to upgrade
their modules. And the OpenMRS collective should behave as if itās
expected, and not constantly second-guess ourselves.
I am investigating an approach which is in line with option 1), ie. modules have to update their required version of OpenMRS.
It seems that the sessionFactory bean configuration in applicationContext can be changed to support either Hibernate 3 or 4. So each version of OpenMRS can use the appropriate version of the hibernate sessionFactory config depending on the hibernate version it supports.
If tests bear this out, then the modules will just have to build to the version of OpenMRS (& hibernate) without any changes. This also does away with the need for the DbSessionFactory wrapper.
I will update this discussion with test results as soon as I have them.
There is need for guidance on this task, regarding webservices.rest.
webservices.rest is actually built to support platform versions 1.8, 1.9,1.10, 1.11 and now 2.0.
The various versions builds on earlier versions, so 1.9 depends on 1.8 etc.
Note because of platform differences it does not seem possible to build webservices.rest-omod-1.8 against openmrs-1.10 for example.
How do I support both DbSessionFactory and SessionFactory in one module side-by-side, ie what is the best way to solve this problem?
How about bumping the versions to the latest maintenance versions of each
release line that has DbSessionFactory?
You could back port DbSessionFactory to 1.8.x in order to take care of the
1.8.x line.