Quick Start - 10 minutes or less

Prerequisites

The only requirements are a current version of Java (JDK 5.0 or better) and the latest version of Maven 2.

If you're new to Maven 2, skim through the Maven Getting Started Guide.

You can also use Ant, but its easier to get started using Maven.

Bootstrap RevGen

Copy the following command and paste it into your console:

mvn archetype:create -DarchetypeGroupId=org.javagen.revgen -DarchetypeArtifactId=maven-archetype-revgen -DarchetypeVersion=1.0-beta1 -DremoteRepositories=http://www.javagen.com/maven/ -DgroupId=org.javagen.revgen.examples -DartifactId=myapp

Note: Make sure you have the latest RevGen release version set for the archetypeVersion value.

This will configure the build and directory layout for a project called myapp and create a database with the following schema:

CREATE TABLE PERSONS (
 ID INT NOT NULL IDENTITY,
 FIRST_NAME VARCHAR(64),
 LAST_NAME VARCHAR(64),
 AGE INT,
 GENDER CHAR(1),
 MOTHER_ID INT,
 FATHER_ID INT,
 
 FOREIGN KEY ( MOTHER_ID ) REFERENCES PERSONS( ID ),
 FOREIGN KEY ( FATHER_ID ) REFERENCES PERSONS( ID ),
 PRIMARY KEY( ID )
);

For convenience we will be using a Hypersonic database plugin (hsql:start) for starting the database on-the-fly. If you prefer you can run the database in the background from a second console (type: ant hsql or mvn hsql:help).

Run RevGen

This step will automatically start a one-time download of the RevGen Plugin and all the other dependencies.

Start the database and generate the persistence code.

 mvn hsql:start revgen:revgen

If Maven complains about RevGen jars, use Ant to download these dependencies and run RevGen again:

 ant getRevgen

Next, compile the resulting code:

 mvn compile

Finally you can run the generated unit tests to verify database access:

 mvn hsql:start test

That's it.

You now have a working persistence layer. This ends the quick-start section.

Want to learn how to customize the generated code? Basic Configuration picks up were this page leaves off...