Databene Benerator:org.postgresql.util.PSQLException:错误:当前事务被中止,命令被忽略,直到事务块结束
Posted
技术标签:
【中文标题】Databene Benerator:org.postgresql.util.PSQLException:错误:当前事务被中止,命令被忽略,直到事务块结束【英文标题】:Databene Benerator: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block 【发布时间】:2016-09-03 03:12:17 【问题描述】:执行mvn benerator:generate
时出错。
错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building generated data data generation project 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- benerator-maven-plugin:0.9.8:generate (default-cli) @ generated-data ---
[INFO] Running file C:\Tools\generated-data\benerator.xml
[INFO] Benerator 0.9.8 build 7
[INFO] Java version 1.8.0_74
[INFO] JVM Java HotSpot(TM) 64-Bit Server VM 25.74-b02 (Oracle Corporation)
[INFO] OS Windows 10 10.0 (amd64)
[INFO] Installed JSR 223 Script Engines:
[INFO] - Oracle Nashorn[nashorn, Nashorn, js, JS, javascript, javascript, ECMAScript, ecmascript]
[INFO] Configured heap size limit: 3628 MB
[INFO] Executing script table_or_view_names_drop.sql
[INFO] Connected to PostgreSQL 9.5.2
[INFO] Using driver PostgreSQL Native Driver PostgreSQL 9.4.1207.jre7
[INFO] JDBC version 4.0
[INFO] Executing script table_or_view_names_create.sql
[ERROR] Error in Benerator execution
java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.databene.commons.ErrorHandler.handleError(ErrorHandler.java:81)
at org.databene.jdbacl.DBUtil.runScript(DBUtil.java:497)
at org.databene.jdbacl.DBUtil.executeScriptFile(DBUtil.java:449)
at org.databene.benerator.engine.statement.EvaluateStatement.runSql(EvaluateStatement.java:262)
at org.databene.benerator.engine.statement.EvaluateStatement.execute(EvaluateStatement.java:165)
at org.databene.benerator.engine.statement.SequentialStatement.executeSubStatements(SequentialStatement.java:52)
at org.databene.benerator.engine.statement.SequentialStatement.execute(SequentialStatement.java:47)
at org.databene.benerator.engine.BeneratorRootStatement.execute(BeneratorRootStatement.java:63)
at org.databene.benerator.engine.DescriptorRunner.execute(DescriptorRunner.java:127)
at org.databene.benerator.engine.DescriptorRunner.runWithoutShutdownHook(DescriptorRunner.java:109)
at org.databene.benerator.engine.DescriptorRunner.run(DescriptorRunner.java:102)
at org.databene.benerator.main.Benerator.runFile(Benerator.java:94)
at org.databene.benerator.main.Benerator.runFromCommandLine(Benerator.java:75)
at org.databene.benerator.main.Benerator.main(Benerator.java:68)
at org.databene.benerator.maven.BeneratorMojo.execute(BeneratorMojo.java:96)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:622)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:458)
at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:406)
at org.databene.jdbacl.proxy.LoggingStatementHandler.executeUpdate(LoggingStatementHandler.java:190)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.databene.commons.BeanUtil.invoke(BeanUtil.java:709)
at org.databene.commons.BeanUtil.invoke(BeanUtil.java:658)
at org.databene.jdbacl.proxy.LoggingStatementHandler.invoke(LoggingStatementHandler.java:105)
at com.sun.proxy.$Proxy26.executeUpdate(Unknown Source)
at org.databene.jdbacl.DBUtil.executeUpdate(DBUtil.java:523)
at org.databene.jdbacl.DBUtil.runScript(DBUtil.java:486)
... 35 more
[INFO] Max. committed heap size: 245 MB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.532 s
[INFO] Finished at: 2016-05-08T14:48:24+03:00
[INFO] Final Memory: 11M/212M
[INFO] ------------------------------------------------------------------------
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my</groupId>
<artifactId>generated-data</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>data generation project</name>
<properties>
<version.dependencies.dbsanity>0.9.4</version.dependencies.dbsanity>
<version.dependencies.webdecs>0.6.10</version.dependencies.webdecs>
</properties>
<dependencies>
<dependency>
<groupId>org.databene</groupId>
<artifactId>databene-benerator</artifactId>
<version>0.9.8</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>dbsanity</artifactId>
<version>$version.dependencies.dbsanity</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>jdbacl</artifactId>
<version>0.8.19</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>databene-webdecs</artifactId>
<version>$version.dependencies.webdecs</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>databene-commons</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>contiperf</artifactId>
<version>1.07</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.databene</groupId>
<artifactId>benerator-maven-plugin</artifactId>
<version>0.9.8</version>
<configuration>
<descriptor>benerator.xml</descriptor>
<encoding>Cp1251</encoding>
<validate>true</validate>
<dbUrl>jdbc:postgresql://localhost:5432/dvdrental</dbUrl>
<dbDriver>org.postgresql.Driver</dbDriver>
<dbSchema>public</dbSchema>
<dbUser>ds</dbUser>
<dbPassword>ds</dbPassword>
<xmlRoot/>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1207.jre7</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
<scope>runtime</scope>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
SQL:
http://pastebin.com/nHhYwjUe
我认为由于 maven benerator 插件是依赖项而不是我自己的源代码,因此我看不到任何方法可以应用此建议的建议(即修改或调试代码):PSQLException: current transaction is aborted, commands ignored until end of transaction block。如何解决?
【问题讨论】:
【参考方案1】:org.postgresql.util.PSQLException: 错误: 无法删除约束 staff_pkey 在表 staff 上,因为其他对象依赖于它详细信息: 表存储上的约束 store_manager_staff_id_fkey 取决于索引 staff_pkey 提示:使用 DROP ... CASCADE 删除依赖对象 也是。
我的错误假设是pgAdmin III
的backup
函数将在sql 文件中生成合适的语句,这些语句将考虑表字段的依赖关系(约束)。必须修改脚本,因为某些 DROP
s 最终带有额外的选项 CASCADE
。
【讨论】:
以上是关于Databene Benerator:org.postgresql.util.PSQLException:错误:当前事务被中止,命令被忽略,直到事务块结束的主要内容,如果未能解决你的问题,请参考以下文章