3.2.2.7. 移植您的 Hibernate 3.5.x 应用程序到 Hibernate 4.x
- 合并 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。 - 修改这个命名空间以遵循下表里注明的新的 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 - 修改环境变量。
- 如果您在使用 Oracle 以及
materialized_clob或materialized_blob属性,全局环境变量hibernate.jdbc.use_streams_for_binary必须设置为 true。 - 如果您在使用 PostgreSQL 以及
CLOB或BLOB属性,全局环境变量hibernate.jdbc.use_streams_for_binary必须设置为 false。