DMV Example

   This example involves a Department of Motor Vehicles database. The main table is DRIVER; it has a one to one dependent realtionship with the ADDRESS, and CONTACT_INFO tables. The DRIVER table contains foriegn key columns that point at the primary keys of these two tables. The ADDRESS and CONTACT_INFO are dependent on DRIVER and are created, and deleted wlong with it. The Driver.java code generated provides get and set methods for the columns in ADDRESS, and CONTACT_INFO tables. If you call Driver.delete() the corresponding rows on the ADRESS and CONTACT_INFO tables will also be deleted.

   Each driver can have zero to many "car"s. The CAR table has a "driver_id" column that is the foreign key that points to the row on the DRIVER table to which this car belongs. New cars can be added to a driver by instantiating a new Car object, calling it's set methods, and then passing it to Driver.addCar(). The Driver.listCars() method returns an iteration of the cars that belong to this driver. If you call Driver.delete() the corresponding rows on the CARS table will also be deleted.

The ddl for creating the table and sequences is in table-definition.sql.
The files driver.xml, address.xml, contact_info.xml, car.xml, contain the details of the tables, and the Java objects we will generate.
The shell command generate.sh invokes the Xalan parser.
It applys the template oracleObjectPersisterTemplate.xsl against the data in the xml files.
The output will be written to Driver.java, Address.java, ContactInfo.java, and Car.java.
Use "compile.sh" to compile the source code.
The "Test.java" class demonstrates how to use the Driver object.
Use "run.sh" to run the Test class.


Back to: XSL template for JDBC Code generation