具有模式的 Arquillian 实体
Arquillian Entities with schema
我正在使用 OpenEJB 设置 Arquillian。我想测试一个可以访问数据库的网络服务。为了测试目的,我能够使用自己的 bean 和实体设置所有内容。
现在我正在添加所有 类 和依赖项并尝试开始测试。但它无法部署,因为我的实体在其 @Table 注释中定义了一个架构。
arquillian.xml
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
<container default="true" qualifier="openejb-embedded-4">
<configuration>
<property name="properties">
testDatabase = new://Resource?type=DataSource
</property>
</configuration>
</container>
</arquillian>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="newejb" transaction-type="JTA">
<jta-data-source>testDatabase</jta-data-source>
<class>[...].AuftragsHistorie</class>
<properties>
<property name="openejb.jpa.init-entitymanager" value="true" />
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
</properties>
</persistence-unit>
</persistence>
AuftragsHistorie.java
@Entity(name = "AuftragsHistorie")
@SequenceGenerator(
name = "AUFTRAGSHISTORY_GENERATOR",
sequenceName = "SEQ_T_PUB_INET_DAF",
allocationSize = 1
)
@Table(
name = "T_PUB_INET_DAF",
schema = "DATA_SCHEMA"
)
public class AuftragsHistorie implements Serializable {
堆栈跟踪的最后一部分
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: invalid schema name: DATA_SCHEMA in statement [CREATE TABLE DATA_SCHEMA.T_PUB_INET_DAF (ID BIGINT NOT NULL, AUFTRAGS_ART_NAME VARCHAR(255) NOT NULL, ERF_DATUM TIMESTAMP NOT NULL, VERS_NR VARCHAR(255) NOT NULL, PRIMARY KEY (ID))] {stmnt 2112059634 CREATE TABLE DATA_SCHEMA.T_PUB_INET_DAF (ID BIGINT NOT NULL, AUFTRAGS_ART_NAME VARCHAR(255) NOT NULL, ERF_DATUM TIMESTAMP NOT NULL, VERS_NR VARCHAR(255) NOT NULL, PRIMARY KEY (ID))} [code=-4850, state=3F000]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:218)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:202)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access0(LoggingConnectionDecorator.java:58)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:913)
at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:118)
at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1231)
at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:976)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:552)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:364)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:341)
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:505)
... 109 more
我已经尝试通过@CreateShema 注释添加模式并添加许多不同的属性,但没有解决问题。
Arquillian 启动一个 HSQL 数据库。
我最终使用了这样的 Arquillian 扩展:
https://github.com/arquillian/arquillian-examples/tree/master/arquillian-lifecycle-extension-tutorial
我在部署前启动一个 H2 数据库,创建所需的模式并在取消部署后将其关闭。
我正在使用 OpenEJB 设置 Arquillian。我想测试一个可以访问数据库的网络服务。为了测试目的,我能够使用自己的 bean 和实体设置所有内容。
现在我正在添加所有 类 和依赖项并尝试开始测试。但它无法部署,因为我的实体在其 @Table 注释中定义了一个架构。
arquillian.xml
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
<container default="true" qualifier="openejb-embedded-4">
<configuration>
<property name="properties">
testDatabase = new://Resource?type=DataSource
</property>
</configuration>
</container>
</arquillian>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="newejb" transaction-type="JTA">
<jta-data-source>testDatabase</jta-data-source>
<class>[...].AuftragsHistorie</class>
<properties>
<property name="openejb.jpa.init-entitymanager" value="true" />
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
</properties>
</persistence-unit>
</persistence>
AuftragsHistorie.java
@Entity(name = "AuftragsHistorie")
@SequenceGenerator(
name = "AUFTRAGSHISTORY_GENERATOR",
sequenceName = "SEQ_T_PUB_INET_DAF",
allocationSize = 1
)
@Table(
name = "T_PUB_INET_DAF",
schema = "DATA_SCHEMA"
)
public class AuftragsHistorie implements Serializable {
堆栈跟踪的最后一部分
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: invalid schema name: DATA_SCHEMA in statement [CREATE TABLE DATA_SCHEMA.T_PUB_INET_DAF (ID BIGINT NOT NULL, AUFTRAGS_ART_NAME VARCHAR(255) NOT NULL, ERF_DATUM TIMESTAMP NOT NULL, VERS_NR VARCHAR(255) NOT NULL, PRIMARY KEY (ID))] {stmnt 2112059634 CREATE TABLE DATA_SCHEMA.T_PUB_INET_DAF (ID BIGINT NOT NULL, AUFTRAGS_ART_NAME VARCHAR(255) NOT NULL, ERF_DATUM TIMESTAMP NOT NULL, VERS_NR VARCHAR(255) NOT NULL, PRIMARY KEY (ID))} [code=-4850, state=3F000]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:218)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:202)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access0(LoggingConnectionDecorator.java:58)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:913)
at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:118)
at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1231)
at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:976)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:552)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:364)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:341)
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:505)
... 109 more
我已经尝试通过@CreateShema 注释添加模式并添加许多不同的属性,但没有解决问题。
Arquillian 启动一个 HSQL 数据库。
我最终使用了这样的 Arquillian 扩展:
https://github.com/arquillian/arquillian-examples/tree/master/arquillian-lifecycle-extension-tutorial
我在部署前启动一个 H2 数据库,创建所需的模式并在取消部署后将其关闭。