我有一个java webapp,
persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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_2.xsd"
version="2.2">
<persistence-unit name="my-persistence-unit">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/qltb"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="my_passwowrd"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDB103Dialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
我创建了一个简单的Bottle
@Entity
类,它只包含一个 id 和一个 String 属性。
当我运行这个 webapp 时,我在日志中看到它正在处理my-persistence-unit
但抛出了一个异常:
org.hibernate.jpa.internal.util.LogHelper.logPersistenceUnitInformation HHH000204: Processing PersistenceUnitInfo [
name: my-persistence-unit
...]
... // Some lines are skipped
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
create table Bottle (
id bigint not null,
color varchar(255),
primary key (id)
) engine=InnoDB" via JDBC Statement
.... // Some lines are skipped
Caused by: org.hsqldb.HsqlException: unexpected token: ENGINE : line: 6
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
为什么 JPA 连接到 hsqldb 而不是 persistence.xml 中声明的 MariaDB?
附加信息:我使用的是 TomEE 8.0.0 M1