【发布时间】:2012-10-12 12:47:53
【问题描述】:
我有两个persistence-units,除了其他使用Hibernate的hbm2ddl create-drop和其他使用validate之外,它们是相同的,并且数据库是由liquiBase创建的。
现在从 Eclipse 运行任何测试(名为 in-mem db 的 HSQLDB),它们工作正常。但是从 maven 运行它们,它们会因奇怪的外键违规而刹车。
我认为奇怪的是,我从 4 个不同的线程收到消息,例如关闭其中一个持久性单元时发生,而表丢弃仍写入控制台。
为什么我会得到四个线程,它们都有自己的 ApplicationContexts?我没有为surefire设置parallel参数,我也没有为maven使用-T开关。
编辑:
这是来自 Maven 命令行输出的 sn-p
Hibernate: drop table PostalCodeDistribution if exists
Hibernate: drop table PublicationAudit if exists
15:21:13.672 [Thread-2] INFO org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'TestPU-nocreate'
Hibernate: drop table PostalCodeDistributionAudit if exists
Hibernate: drop table PublicationInvoicing if exists
Hibernate: drop table PostalCodeSubscriberCountAudit if exists
15:21:13.672 [Thread-2] INFO org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000030: Cleaning up connection pool [jdbc:hsqldb:mem:ptptest]
Hibernate: drop table Revision if exists
Hibernate: drop table PriceDate if exists
【问题讨论】:
标签: spring hibernate maven junit liquibase