More control at creating AUTO_PK_SUPPORT table

From: Borut Bolčina (borut.bolcin..mail.com)
Date: Thu Apr 24 2008 - 09:36:20 EDT

  • Next message: Tomi N/A: "rich client db security in an untrusted environment"

    Me again,

    when running DbGenerator with:

            generator.setShouldCreatePKSupport(true);

    it would be GREAT if one could control if the DELETE and INSERT statements
    should be executed (maybe even automatically based on error at CREATE). The
    method could be:

            generator.setShouldCreatePKSupport(true, false);

    where second false would suppress the execution of DELETE FROM
    AUTO_PK_SUPPORT and INSERT INTO AUTO_PK_SUPPORT if CREATE fails.

    What do you think?

    Sample output:

     INFO [14:49:11.712] CREATE TABLE AUTO_PK_SUPPORT ( TABLE_NAME CHAR(100)
    NOT NULL, NEXT_ID BIGINT NOT NULL, UNIQUE (TABLE_NAME))
     INFO [14:49:11.712] *** error.
    com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'AUTO_PK_SUPPORT'
    already exists
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
            at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
            at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
            at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)
            at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
            at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:734)
            at
    org.apache.cayenne.access.DbGenerator.safeExecute(DbGenerator.java:352)
            at
    org.apache.cayenne.access.DbGenerator.runGenerator(DbGenerator.java:330)
            at
    com.interseek.portal.server.Bootstrap.createTables(Bootstrap.java:155)
            at com.interseek.portal.server.Bootstrap.<init>(Bootstrap.java:58)
            at com.interseek.portal.server.Bootstrap.main(Bootstrap.java:71)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:271)
            at java.lang.Thread.run(Thread.java:595)
     INFO [14:49:11.712] DELETE FROM AUTO_PK_SUPPORT WHERE TABLE_NAME IN
    ('table1', 'table2', 'table3')
     INFO [14:49:11.728] INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID)
    VALUES ('table1', 200)
     INFO [14:49:11.728] INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID)
    VALUES ('table2', 200)
     INFO [14:49:11.728] INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID)
    VALUES ('table3', 200)

    Cheers,
    Borut



    This archive was generated by hypermail 2.0.0 : Thu Apr 24 2008 - 09:36:55 EDT