Best way to share hibernate configuration across projects

Go To StackoverFlow.com

2

We have couple different web-apps that share the same db link. The hibernate layer in each web-app is a jar copy of the "*.hbm.xml" and java files. Over time, I am worried about inconsistencies creeping into each copy, people forgetting to create jar file.

Is there a better way to share the same db hibernate information across multiple projects than just creating jar files ?

2012-04-04 22:13
by Ender Wiggin
If you are using [tag:maven] then sharing a JAR file across several projects is the right way to go, no to mention you get full versioning support - Tomasz Nurkiewicz 2012-04-04 22:21
I echo Tomasz's comment. We do this and it works like a charm - TechTrip 2012-04-04 22:44


2

This is entirely a build & deployment problem. If your hibernate entities are in a different package, then you should build that package before the apps, and package the resulting jar with them.

Maven makes this easy:

  • a multi-module project
  • a jar-packaged module that contains the entities
  • war-packaged modules that have a <dependency> on the jar
  • the same version across all modules.
2012-04-04 22:29
by Bozho
I was thinking this is the only possible way. From what I read, it does simplify things but this is a small development shop with no resources for such things. I guess I can actually use svn:extensions as well and pull the same source across multiple projects. Not sure which is easier... - Ender Wiggin 2012-04-04 22:59
Ads