【发布时间】:2015-07-09 13:31:34
【问题描述】:
我想创建基于实体的数据库。配置:
- Glassfish:GlassFish Server 开源版 4.1(内部版本 13)
- Eclipselink:Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd(随 glassfish 一起提供)
- 数据库:PostgreSQL 版本:9.4.2
- 驱动程序:PostgreSQL 原生驱动程序版本:PostgreSQL 9.4 JDBC4.1(内部版本 1201)
从 eclipselink 开始创建数据库的那一刻起,我在将大量日志参数置于最佳状态后,在日志中看到以下语句:
- SELECT ID FROM table_name WHERE ID ID
- 选择 1
重复 4-5 次。第一个查询给出以下明显的 postgres 错误:
org.postgresql.util.PSQLException:错误:关系“table_name”不存在 职位:16
因此,以下查询给出以下错误:
org.postgresql.util.PSQLException: 错误: 当前事务被中止,命令被忽略直到事务块结束
在这个 eclipselink 继续创建表之后:
CREATE TABLE table_name (ID BIGINT NOT NULL, PRIMARY KEY (ID))
但是会产生同样的错误。
由于某种原因,创建数据库发生在事务中。我找到了负责的源代码,但我找不到事务是如何启动的。我可以提供更详细的信息,但也许现在已经有人可以提供帮助了。
编辑: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="h ttp://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="AntennasOperatingSystemServerPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>MyDatabase</non-jta-data-source>
<class>... bunch of classes ... </class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.DefaultSessionLog"/>
<property name="eclipselink.deploy-on-startup" value="true"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<property name="eclipselink.logging.level.sql" value="FINEST"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.target-database" value="PostgreSQL" />
</properties>
</persistence-unit>
</persistence>
【问题讨论】:
-
您找到解决方案了吗?
标签: postgresql eclipselink glassfish-4