3.2.2.7. 移植您的 Hibernate 3.5.x 应用程序到 Hibernate 4.x


  1. 合并 AnnotationConfiguration 到配置里。
    AnnotationConfiguration 已废弃,它不应该影响应用程序的移植。
    如果您还在使用 hbm.xml 文件,您应该意识到 JBoss EAP 6 现在在 AnnotationConfiguration 里使用 org.hibernate.cfg.EJB3NamingStrategy,而不是以前版本里的 org.hibernate.cfg.DefaultNamingStrategy。这可能导致命名不匹配。如果您依赖于这个命名策略来设置关系(多对多和元素集合)表的默认名称,您可能会遇到这个现象。要解决这个问题,您可以调用 Configuration#setNamingStrategy 传入 org.hibernate.cfg.DefaultNamingStrategy#INSTANCE 让 Hibernate 使用旧的org.hibernate.cfg.DefaultNamingStrategy
  2. 修改这个命名空间以遵循下表里注明的新的 Hibernate DTD 文件名称规则。
    Expand
    表 3.6. DTS 命名空间映射表
    以前的 DTD 命名空间 新的 DTD 命名空间
    http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd
  3. 修改环境变量。
    1. 如果您在使用 Oracle 以及 materialized_clobmaterialized_blob 属性,全局环境变量 hibernate.jdbc.use_streams_for_binary 必须设置为 true。
    2. 如果您在使用 PostgreSQL 以及 CLOBBLOB 属性,全局环境变量 hibernate.jdbc.use_streams_for_binary 必须设置为 false。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat