我应该在服务器启动时检查表是否存在。如果它们不存在,我必须使用实体类创建它们。这甚至可能吗?我正在使用 Eclipse,我的服务器是 wildfly10。我正在连接到 Oracle 11g xe,但我认为不是数据库导致了问题
无论如何,这是我到目前为止所做的
我的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
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">
<persistence-unit name="Lab5">
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
如果没有上述属性,我的数据库查询将引发异常。但真正奇怪的是,使用此属性查询返回空列表,但数据库中不存在表。另外,我注意到服务器启动时显示警告
HHH000431: Unable to determine H2 database version, certain features may not work
我尝试了对在 stackoverflow 和其他网站上发现的这个警告的各种修复,但它们没有帮助。我什至不知道这是否与我的问题有关