views:

513

answers:

2

We have a project consisting of multiple subprojects. With each subproject we potentially have some hibernate mapping files but in the end only one actual hibernate session. Those subprojects could be combined in several ways, some depend on each other. My problem is that actually I want to have a SessionFactoryBean which would be able to collect those mappings/mappinglocations from the applicationContext(s) and configure itself.

Has somebody written something like this, or do I have to do it myself (I envision something a bit like the urlresolver or viewresolver functionality from SpringMVC)?

A: 

LocalSessionFactoryBean has a configLocations property. You inject the list of config locations, and it will gather tham together for a single session factory configuration.

skaffman
+1  A: 

Another (and simpler) approach would be to gather all your model classes in one project. Make all your other projects depend on it and have your SessionFactory created there. That is how I managed to solve the same problem and it works pretty well.

bernardn