【发布时间】:2016-06-25 05:10:13
【问题描述】:
我想做什么
我正在尝试从 WildFly 8.2.0 迁移到 WildFly 10.0.0,这意味着我已经(并且想要)从 Hibernate 4.3 迁移到 Hibernate 5.0。
设置
Java 8u40
Spring 4.1.9
SQL Server 2012
Wildfly 8.2.0 -> Wildfly 10.0.0
Hibernate 4.3.6 -> Hibernate 5.0.7
我已经阅读了migration guide 并且对命名策略 的更改感到震惊。我havereadmanyquestions关于这个,但我的似乎有点不同。 Hibernate 抱怨找不到表:
INFO [o.h.Version] HHH000412: Hibernate Core {5.0.7.Final}
INFO [o.h.cfg.Environment] HHH000206: hibernate.properties not found
INFO [o.h.cfg.Environment] HHH000021: Bytecode provider name : javassist
INFO [o.h.annotations.common.Version] HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
INFO [o.h.dialect.Dialect] HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
INFO [o.h.envers.boot.internal.EnversServiceImpl] Envers integration enabled? : true
INFO [o.h.validator.internal.util.Version] HV000001: Hibernate Validator 5.2.3.Final
INFO [o.h.tool.hbm2ddl.SchemaValidator] HHH000229: Running schema validator
INFO [o.h.t.s.e.i.InformationExtractorJdbcDatabaseMetaDataImpl] HHH000262: Table not found: SEC_AUTHORIZATION_RULES
INFO [o.h.t.s.e.i.InformationExtractorJdbcDatabaseMetaDataImpl] HHH000262: Table not found: SEC_USER
More tables not found ...
INFO [o.h.hql.internal.QueryTranslatorFactoryInitiator] (ServerService Thread Pool -- 62) HHH000397: Using ASTQueryTranslatorFactory
当我切换到调试日志记录时,我看到例如他将实体绑定到正确的数据库表:
DEBUG [o.h.c.a.EntityBinder] Bind entity com.company.user.User on table SEC_USER
DEBUG [o.h.c.Ejb3Column] Binding column: Ejb3Column{table=org.hibernate.mapping.Table(SEC_USER), mappingColumn=ID, insertable=true, updatable=true, unique=false}
对我来说奇怪的是该应用程序可以正常工作。在此Table not founds 之后,它不会抱怨架构不正确。该应用程序有效。选择、插入、更新数据有效。
我已经通过它的 spring-orm 抽象配置了休眠:
@Bean(name = "myEmf")
@DependsOn({"dataSource", "flyway"})
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(new String[]{"com.company.**.*"});
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;
}
private Properties additionalProperties() {
Properties propFile = propertiesFile();
properties.setProperty("hibernate.hbm2ddl.auto", "validate");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServer2012Dialect");
properties.setProperty("hibernate.show_sql", "false");
properties.setProperty("hibernate.format_sql", "true");
properties.setProperty("hibernate.id.new_generator_mappings", "false");
properties.setProperty("hibernate.use_sql_comments", "false");
properties.setProperty("hibernate.implicit_naming_strategy", "legacy-jpa");
return properties;
}
在这个对应的实体中,我有明确命名的表名和列名:
@Entity
@Table(name = "SEC_USER")
public class User extends BaseEntity {
@Column(name = "LOGIN", nullable = false, unique = true)
private String login;
问题
- 如何使未找到此表的日志消息消失?
- 如果我有明确命名的表名,为什么它们会出现?
- 他为什么不抱怨列名?
- 为什么他看起来工作正常?
我尝试过的
- 将 Spring 4.1.9 升级到 4.2.5 says he has support for Hibernate 5
- 根据this将hibernate.implicit_naming_strategy设置为legacy-jpa
我已经对 hibernate 进行了一些调试,并且我在 InformationExtractorJdbcDatabaseMetaDataImpl.java 中发现 hibernate 看不到目录(无论是什么)和架构。至少我认为他应该看到架构。请参见下面的屏幕截图:目录和架构为空。
【问题讨论】:
标签: java spring hibernate wildfly hibernate-5.x