Databene Benerator:org.postgresql.util.PSQLException:错误:当前事务被中止,命令被忽略,直到事务块结束

时间:2016-05-08 12:00:34

标签: java postgresql maven transactions benerator

执行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 个答案:

答案 0 :(得分:0)

  

org.postgresql.util.PSQLException:错误:无法删除约束   staff_pkey表工作人员,因为其他对象依赖于它详细信息:   表存储上的约束store_manager_staff_id_fkey取决于索引   staff_pkey提示:使用DROP ... CASCADE删除依赖对象   太

我错误地认为 {% block content %} <div itemprop="video" itemscope itemtype="http://schema.org/VideoObject"> <meta itemprop="thumbnailUrl" content="{{post.image_url}}" /> <meta itemprop="embedURL" content="{{post.video_path}}" /> <meta itemprop="uploadDate" content="{{ post.publish }}" /> <h2 id="detail-h1"> <span itemprop="name">{{ post.title }}</span> </h2> {% if post.video %} <div class="embed-responsive embed-responsive-16by9"> <iframe src="{{post.video_path}}?autoplay=1&autohide=1" class="embed-responsive-item" frameborder="0" controls="0" allowfullscreen> </iframe> </div> {% else %} {% if post.image_url %} <img src="{{post.image_url}}" class="img-responsive"> {% else %} <p>upload an image</p> {% endif %} {% endif %} <div style="margin-top: 10px; background: white; padding: 10px 10px 10px 10px;"> <span> <p style="float: left"> {% if post.author %} Author: {{post.author}} {% endif %} </p> <p style="float: right" id="pub"> {%if post.draft %}<span id="draft">Draft </span>{% endif %} Publicado: {{ post.publish|date }} </p> </span> <p class="tags" style="clear: both">Tags: {% for tag in post.tags.all %} <a href="{% url 'blog:post_list_by_tag' tag.slug %}"> {{ tag.name }} </a> {% if not forloop.last %}, {% endif %} {% endfor %} </p> {% if user.is_authenticated %} <p> <a href="{% url 'blog:delete' post.id %}" class="btn" role="button">delete</a> <a href="{% url 'blog:update' post.slug %}" class="btn" role="button">edit</a> </p> {% endif %} <p>Share on: <a href="https://www.facebook.com/sharer/sharer.php?u={{ request.build_absolute_uri }}" class="btn btn-social-icon btn-facebook" target="_blank"> <span class="fa fa-facebook"></span> </a> <a href="https://twitter.com/home?status={{ instance.content | truncatechars:80 | urlify }}%20{{ request.build_absolute_uri }}" class="btn btn-social-icon btn-twitter" target="_blank"> <span class="fa fa-twitter"></span> </a> <a href='https://plus.google.com/share?url={{ request.build_absolute_uri }}' class="btn btn-social-icon btn-google" target="_blank"> <span class="fa fa-google"></span> </a> <a href="https://www.linkedin.com/shareArticle?mini=true&url={{ request.build_absolute_uri }}&title={{ instance.title }}&summary={{ share_string }}&source={{ request.build_absolute_uri }}" class="btn btn-social-icon btn-linkedin" target="_blank"> <span class="fa fa-linkedin"></span> </a> </p> </div> <div style="margin-top: 10px; background: white; padding: 10px 10px 10px 10px;"> <p class="content-markdown"><span itemprop="description">{{post.body}}</span></p> </div> <div style="margin-top: 10px; background: white; padding: 10px 10px 10px 10px; margin-bottom: 10px"> <div id="disqus_thread"></div> </div> </div> {% endblock content %} {% block aside %} <h3 class="">Similar Posts</h3> <hr style="margin:10px"> <div class="row"> {% for post in similar_posts %} <div class="col-xs-12 col-sm-4 col-md-4 col-lg-12" id="similar"> <div class="thumbnail thumb"> <h6 id="date">{{ post.publish|date }}</h6> {% if post.image %} <img src="{{post.image.url}}" class="img-responsive post"> {% elif post.image_url %} <img src="{{post.image_url}}" class="img-responsive post"> {% else %} <p>upload an image</p> {% endif %} <div class="caption"> <a href="{{ post.get_absolute_url }}"> <h5 class="post-title" id="title">{{post.title}}</h5> </a> {% if user.is_authenticated %} <p> <a href="{% url 'blog:delete' post.id %}" class="btn" role="button">delete</a> <a href="{% url 'blog:update' post.slug %}" class="btn" role="button">edit</a> </p> {% endif %} </div> </div> </div> {% empty %} <p id="para">There are no similar posts yet.</p> {% endfor %} </div> {% endblock aside %} backup函数会在sql文件中生成合适的语句,这些语句将考虑表的字段的依赖关系(约束)。脚本必须被中等化,有些pgAdmin III最终会有额外的选项DROP