Speedo user manual: Data structure management

  1. Creation of the data structure
  2. The SQL script ant task

Back to the Speedo documentation

    Creation of the data structure

    Speedo through Jorm is able to create automaticaly the data structure on the persistent support. This feature is activated with regards to the property org.objectweb.speedo.mappingStructure of the speedo-jdo.properties (or speedo-ejb.properties according to the speedo personnality you use) configuration file.
    However in application servers with XA connector some persistent supports are able to create data structure (SQL relations for example) inside an XA transaction. Then we advice you to create data structures before to launch your application. To do this Speedo provides a simple tool class named 'org.objectweb.speedo.tools.DataStructureCreation'. An ant target 'createDataStruct' is also provided inside the build.xml of the speedo distribution and inside the bank example. This target launches the tools class with regards to the following usage:

    DataStructureCreation (<class name to initialize> | <.jdo file name>)*
    [-Djavax.jdo.option.DriverClassName=<driver class name>]
    [-Djavax.jdo.option.ConnectionURL=<database url>]
    [-Djavax.jdo.option.ConnectionUserName=<user name>]
    [-Djavax.jdo.option.ConnectionPassword=<user password>]

    The SQL script ant task


    Speedo is able to generate the script of the database creation, even in disconnected mode (regarding the database). The provided ant task generates the sql script of the database creation into the file of your choice. The ant task is : org.objectweb.speedo.ant.AntSpeedoScriptGenerator.


    Attribute Description Required
    Is the name of the file in which the script is written. Yes
    Is the name of the mapper for which you want to generate the script. It cannot be rdb.automatic.
    src Is the location of the source to process. Yes
    classpathref Is the classpath containing Speedo, the user classes, and the configuration files (etc directory). Yes
    generateDrop Indicates if the drop statements must be generated or not. Default value is true.
    Indicates if the delete statements must be generated or not. Default value is true. No
    Indicates if the create statements must be generated or not. Default value is true. No

    Parameters specified as nested elements


    The following example comes from the invoice example:

    <property name="build"	value="${basedir}/build"/>
    <property name="dist" value="${basedir}/../.."/>
    <property name="etc" value="${dist}/etc"/>
    <path id="classpath">
    <pathelement location="${etc}"/>
    <pathelement location="${build}"/>
    <fileset dir="${dist}">
    <include name="speedo.jar"/>
    <include name="lib/log/log4j.jar"/>
    <include name="lib/jdbc/*.jar"/>
    <target name="generate.script" depends="compile">
    <taskdef name="generate" classname="org.objectweb.speedo.ant.AntSpeedoScriptGenerator">
    <classpath refid="classpath"/>
    <generate destFile="dbCreation.sql" mapperName="rdb.postgres"
    src="${build}" classpathref="classpath"/>
        As no "includes" was defined in the generate task, by default all **Mapping.class files present in the src directory will be processed.
        As netiher generateDrop, neither generateDelete, nor generateCreate properties were defined by the user, all will be set to true by default and the script will include drop, delete and create         statements.