使用Hibernate时,Play Framework 2.6 Evolutions无效

时间:2017-11-17 16:24:01

标签: java hibernate jpa playframework

您好我最近从Ebeans迁移到了Hibernate,突然Play的数据库演变不再起作用了。我在persistence.xml

中禁用了hibarnate ddl创建
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">

  <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL92Dialect"/>
      <property name="hibernate.hbm2ddl.auto" value="none"/>
    </properties>
  </persistence-unit>
</persistence>

我的application.conf看起来像这样

# This is the main configuration file for the application.
# https://www.playframework.com/documentation/latest/ConfigFile


# Point JPA at our database configuration
jpa.default=defaultPersistenceUnit

# Number of database connections
# See https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
fixedConnectionPool = 9

play.http.secret.key="RJr?nE5jHzAXtqvvnB6^pe0sQUGQX4@0df^Qlsev2EEEA43z0HfS6sz1?uob?b5]"

db.default {
  driver = org.postgresql.Driver
  url = "jdbc:postgresql://192.168.155.177/legato"
  username = "vagrant"
  password = "vagrant"
  jndiName = DefaultDS
}

applyEvolutions.default=true

# disable the built in filters
play.http.filters = play.api.http.NoHttpFilters

# Job queue sized to HikariCP connection pool
post.repository {
  executor = "thread-pool-executor"
  throughput = 1
  thread-pool-executor {
    fixed-pool-size = ${fixedConnectionPool}
  }
}

行为是hibernate正确地没有生成数据库但是Play也不会生成任何进化脚本。如果我在开发模式下启动应用程序,它将工作并在查询数据库时抛出PersistenceException,因为没有表退出。

有人可以帮助我吗?

0 个答案:

没有答案