DB Generation

From: mr.abanjo (mr.abanj..mail.com)
Date: Wed Jan 14 2009 - 08:46:49 EST

  • Next message: Michael Gentry: "Re: DB Generation"

    Hi,i have configured a simple cayenne datamap for my application with 2
    table.
    All works fine, i can read/write into them without problem.

    Now, i want to create at runtime the database schema, so if is the first
    time and the database is empty i can generate it on the fly.
    I do it with this code (taken from petstore sample in cayenne's wiki):

          DataDomain domain =
    Configuration.getSharedConfiguration().getDomain();

          DataNode node = getDataNode(domain);
          DbGenerator generator = new DbGenerator(node.getAdapter(),
    getDataMap(domain));
          try {
            generator.runGenerator(node.getDataSource());
          } catch (Exception e) {
            throw new Exception("Error generating DB schema", e);
          }

    If i test this code on a HSQLDB it works well.
    The strange thing is that after execution i have 3 tables instead of 2...
    infact there is also "AUTO_PK_SUPPORT" that i haven't defined in my datamap.
    I suppose that it is a table used by canyenne.

    But if i test it on MYSQL db it doesn't work.
    ONLY the "AUTO_PK_SUPPORT" is created.

    Anyone have idea why the same code works in 2 different way?

    The user that i use to connect to mysql haves all privileges.

    Thanks
    Davide



    This archive was generated by hypermail 2.0.0 : Wed Jan 14 2009 - 08:47:24 EST