Previous Index Next

7 Generator Tools

Standalone AuDAO is a set of Java libraries allowing you to generate SQLs and Java DAO sources locally on your computer. This chapter describes these tools which help you to generate, compile and package DAO libraries.

7.1 Apache Ant Tools

Apache Ant is commonly used for developing Java projects. Currently we support Apache Ant 1.7 and newer. For more information please see the Apache Ant project.

7.1.1 Predefined High-Level Ant Targets

The standalone AuDAO tool contains Apache Ant build XML fragments in the directory AUDAO_HOME/tools:

  • build-audao.xml - for compiling DAO for standard databases
  • build-audao-gae.xml - for compiling DAO for Google App Engine (both gae and gaejdo)

Either you develop for standard databases (Oracle, MySQL or HSQLDB) or for Google App Engine you need to import the correct build file fragment into your project's build.xml.

But before you import the fragment you need to define Ant property audao.home which should point to the directory where your AuDAO instance si located.

If you are importing the build-audao-gae.xml, then you also need to define Ant property gae.home which should point to the directory where your Google App Engine SDK instance is located. So you can also use build-audao-gae.xml for standard database projects, but you need to have GAE SDK installed and the gae.home property set.

The following example of Ant's build.xml shows how a DAO layer for standard database project can be generated, compiled and JARer by one command:

<?xml version="1.0"?>
<project name="test" basedir="." default="dist">

  <property name="audao.home" location="/usr/local/audao-1.3"/>

  <import file="/tools/build-audao.xml"/>

  <target name="dist">
    <antcall target="audao-jar">
      <param name="audao-xml" location="src/my-config.xml"/>
      <param name="audao-gen-dir" location="build/audao"/>
      <param name="audao-dbtype" value="oracle"/>
      <param name="audao-package" value=""/>
      <param name="audao-jar" location="dist/test-db-oracle.jar"/>


The following table shows all predefined AuDAO targets:

AuDAO Predefined Target Name Description
audao-generate generates Java DAO sources and SQL scripts
audao-compile generates Java DAO sources and SQL scripts; compiles Java classes
audao-jar generates Java DAO sources and SQL scripts; compiles Java classes; creates JAR library

The following table shows the parameters of all predefined AuDAO targets:

Parameter audao-generate audao-compile audao-jar Description
audao-xml yes* yes yes the source configuration XML file location
audao-gen-dir yes yes yes the destination directory for generating files; it is automatically created if it does not exist
audao-dbtype yes yes yes the target database type (mysql|oracle|gae|gaejdo|hsqldb)
audao-package yes yes yes the Java package where to generate the DAO to (e.g. "")
audao-jar yes yes yes the location of the target JAR file; the parent directories are automatically created if do not exist
audao-debug yes yes yes true/false flag for debugging
audao-debug-level yes yes yes commons-logging debug level
audao-dto-gwt-serializer yes yes yes true/false to generate GWT custom field serializers for DTOs
audao-option-generate yes yes yes a comma separated list of types to be generated: DTO, DTO_IMPL (only gaejdo), DTO_GWT_SERIALIZER, DAO, DAO_IMPL, FACTORY, FACTORY_IMPL, SQL_CREATE, SQL_DROP
audao-compile-pathid no yes yes contains classpath refid of a custom classpath for compilation
java-version no yes yes Java version used for javac - obtained from runtime by default
audao-exclude-xml no no yes if set, then the source config XML is not included in the JAR
*) The mandatory parameters are bolded

Using of predefined Ant targets is the recommended way how to invoke AuDAO.

7.1.2 AuDAO Ant Task

You can also call the AuDAO Ant task directly, but there exist some traps with passing correct classpath to it.

The example of Ant's build.xml:

  <property name="audao.home" location="/usr/local/audao-1.3"/>

  <path id="audao.path">
    <fileset dir="" includes="*.jar"/>
    <fileset dir="/lib" includes="*.jar"/>


  <target name="audao">

The problem of the previous example is the way how Ant instantiates custom tasks with conjunction of the way how Java looks for XML, XSL and XPath Factories (e.g. javax.xml.transform.TransformerFactory as for XSL). Although the task audao is well defined and all libraries are found by Ant in runtime (mainly xalan.jar), the Java itself loads different TransformerFactory than is defined by xalan.jar - because it uses system classloader rather than the one defined by Ant for the audao task.

So, the problem is that different XSLT implementations produce different results. As we chose Xalan as the XSLT implementation, we cannot guarantee that other XSLT implementation will produce correct results.

If you really want to call this task directly, then you need to provide Xalan libraries to the Ant on the system level either by:

  • invoking ant with the -lib option: ant -lib /usr/local/audao-1.3/lib my-build.xml
  • copying AuDAO's libraries into $HOME/.ant/lib
  • copying AuDAO's libraries into $ANT_HOME/lib

7.2 Plain Java Tools

Currently we support only generating of DAO layer and SQL scripts.

7.2.1 (UNIX)

The UNIX script is located in the directory AUDAO_HOME/bin. The invocation is as follows:

usage: [OPTIONS] {oracle|mysql|gae|hsqldb} PACKAGE INPUT_XML {OUTPUT_DIR|}
        -g FILE_TYPES   or --generate FILE_TYPES
                generates only specified types
                FILE_TYPES is a comma separated list of file types:
                        dto - the DTO files
                        dao - the DAO files
                        dao_impl - the DAO implementation files
                        factory - the factory file
                        factory_impl - the factory implementation file
                        sql_create - the SQL create file
                        sql_drop - the SQL drop file
                        dto_impl - the DTO implementation files (GAE only)
                        dto_gwt_serializer - the GWT custom serializer of DTOs files

        -s      or --generate-dto-gwt-serializer
                generates GWT customs serialzier for DTOs
$ oracle my-config.xml build/src-gen
The previous command runs AuDAO on the source config my-config.xml into Java package and using Oracle implementation. The output is generated into directory build/audao.

You can generate directly into z ZIP file which is recognized by the ".zip" suffix:

$ oracle my-config.xml

7.2.2 Java Main Class (Universal)

The UNIX script actually invokes the Java class com.spoledge.audao.generator.Main. The parameters are exactly the same as passed to the script.

Previous Index Next
Free Online Tool

Try our free online DAO generator.

Upload the configuration XML file and get the generated SQL scripts and Java classes for free !

Free GQL Parser

Download source or binary of our open-source GQL parser.

Query q =
 new GqlDynamic()
   "SELECT * FROM Ent");
All GQL features are supported. More...