在多个项目中使用相同的hibernate映射文件 [英] Using same hibernate mapping files across multiple projects

查看:117
本文介绍了在多个项目中使用相同的hibernate映射文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有几个java SE应用程序使用相同的库,并通过Hibernate(而不是JPA)使用同一个数据库。我在哪里放置hibernate映射文件和hibernate配置? (所以什么可以提取到图书馆?)

解决方案

将库中所有应用程序共有的所有内容与库之外的特定应用程序(数据库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.

这篇关于在多个项目中使用相同的hibernate映射文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆