1. Download

  1. First make sure you have the Java Development Kit installed. OneWebSQL™ ERwin2Java requires Java 1.6 or higher.
  2. If you want to use the Maven plugin, make sure you have Maven installed. The OneWebSQL™ ERwin2Java Maven plugin requires Maven 2.
  3. Download the OneWebSQL™ ERwin2Java zip file from http://OneWebSQL.com/download.

    The zip file includes:
    • INSTALL.txt - installation guide
    • README.txt - project description
    • install.sh, install.bat - installation scripts
    • gen.sh, gen.bat - code generation scripts
    • example folder - contains example files for use with OneWebSQL™ ERwin2Java
    • several .jar files including OneWebSQL™ ERwin2Java itself and related libraries

2. Installation

2.1. Installation with Maven

If you want to use OneWebSQL™ with Maven you need to install OneWebSQL™ code generation plugin.

2.1.1. Installation in Linux

  1. Unzip the archive.
  2. Run
    ./install.sh
    
    The script installs the plugin in your local repository. You will see the following output as the installer is running:
    Installing OneWeb SQL ERwin Schema -> Java Generator, version 1.0.3
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'install'.
    
    ...
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: < 1 second
    [INFO] Finished at: Thu Feb 23 13:52:15 CET 2012
    [INFO] Final Memory: 3M/77M
    [INFO] ------------------------------------------------------------------------
    
  3. The OneWebSQL™ ERwin2Java Maven plugin is now installed.

2.1.2. Installation in Windows

  1. Unzip the archive.
  2. Run
    install.bat
    
    The script installs the plugin in your local repository. You will see the following output as the installer is running:
    Installing OneWeb SQL ERwin Schema -> Java Generator, version 1.0.3
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'install'.
    
    ...
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: < 1 second
    [INFO] Finished at: Thu Feb 23 13:52:15 CET 2012
    [INFO] Final Memory: 3M/77M
    [INFO] ------------------------------------------------------------------------
    
  3. The OneWebSQL™ ERwin2Java Maven plugin is now installed.

2.2. Installation as a standalone tool

Just unzip the archive and you're done.

3. Generate classes

3.1. Class generation with Maven

If you use Maven 2, you may use the Maven plugin version of OneWebSQL™ ERwin2Java.

3.1.1. Example project

In the example directory there is an example project. To compile the project, go to the example directory and run:

mvn compile

This will generate the same classes that come with the standalone version. The source files are generated in the target/generated-sources/onewebsql directory.

3.1.2. Set up your project

To use the OneWebSQL™ ERwin2Java Maven plugin, you will need to edit your project's pom.xml file so you can set up the model file and target Java package properties.

  1. To add maven-onewebsql-erwin2java-plugin to your project, add the following lines to your pom.xml file, in the <plugins> section:

    ...
      <plugins>
    ...
        <plugin>
          <groupId>com.onewebsql</groupId>
          <artifactId>maven-onewebsql-erwin2java-plugin</artifactId>
          <version>1.0.3</version>
          <executions>
            <execution>
              <id>common</id>
              <phase>generate-sources</phase>
              <goals>
                <goal>generate</goal>
              </goals>
              <configuration>
                	<!-- xml model files  -->
    	   	<model_sets>
    			<fileset>
    				<directory>example</directory>
    				<includes>
    					<include>example-model.xml</include>
    				</includes>
    			</fileset>
    	   	</model_sets>
    		<!-- name of the Java package for generated classes -->
    		<java_default_package>com.example</java_default_package>
              </configuration>
            </execution>
          </executions>
        </plugin>
    ...
    </plugins>
    ...
    
  2. Ensure that you are using Java 1.6 or higher by adding these lines in the <plugins> section as well:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.6</source>
        </configuration>
    </plugin>
    
  3. Compile the project by running this line of code:
    mvn compile
    

3.1.3. Eclipse integration

Once the source files have been generated, run

mvn eclipse:eclipse

and refresh your Eclipse project. The generated classes will be marked as source folders in Eclipse. You can use them in your code.

3.2. Class generation with standalone tool

In Linux run

./gen.sh

In Windows run

gen.bat

The script generates .java files from the example model example/example-model.xml. The source files are generated in the target/generated-sources/onewebsql directory.

Copy the generation script into your project folder and adjust its contents as needed. The details for setting up code generation are in the Code Generation Guide.