且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在多个项目中使用相同的hibernate映射文件

更新时间:2023-11-22 09:56:04

将库中所有应用程序共有的所有内容与库之外的特定应用程序(数据库URL,用户,密码,但也可能是缓存选项等)相关。

到那时,所有内容都从classpath中加载。无论文件是在一个jar文件中还是另一个文件文件对Hibernate都无关紧要。



如果您使用注释,则大多数配置都将位于实体类中。


There are several java SE apps using the same library and working with the same database via Hibernate (not JPA). Where do I put hibernate mapping files and hibernate config? (so what can be extracted to the library?)

Put everything that is common to all applications in the library, and everything related to a specific application (database URL, user, password, but maybe also caching options, etc.) outside of the library.

At then end, everything is loaded from the classpath. Whether the files are in one jar or another doesn't matter for Hibernate.

If you use annotations, most of the configuration will be in the entity classes anyway.