Generate DDL/SQL using startSQLRepository

One of the beauty of ATG is,it can generate DDL 
from a Repository Definition file.
eg: Below is a sample repository EmployeeRegistration with 4 columns in the module EmployeeRegistration.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gsa-template SYSTEM "dynamosystemresource:/atg/dtds/gsa/gsa_1.0.dtd">
<gsa-template>
<item-descriptor name="EmployeeInfo">
  <table name="emp_info" type="primary" id-column-names="id">
    <property name="id" column-name="id" data-type="string"/>
    <property name="empId" column-name="emp_id" data-type="int"/>
    <property name="empName" column-name="emp_name" data-

    type="string"/>
    <property name="empDept" column-name="emp_dept" data-

    type="string"/>
  </table>
 </item-descriptor>
</gsa-template>

So to generate a DDL for this you need to simply execute the below line.

startSQLRepository -m EmployeeRegistration -repository
/empRegistration/repositories/EmployeeRegistrationRepository -outputSQL

You need to verify two things before executing this command

1. Your Database connector files are there in the classpath.

   You can  execute the command below to set up the 
   classpath in windows environment.This is faster.

   SET CLASSPATH=C:\ATG\ATG10.0.3\home\locallib\

   mysql-connector-java-5.X.XX-bin.jar;%CLASSPATH%

2. You have to put the  JTDatasource,fakeXADatasource components

   with appropriate connection details in the path
   C:\ATG\ATG10.0.3\home\localconfig\atg\dynamo\service\jdbc
JTDatasource.properties

The JTDatasource has to point to FaxeXADataSource.This component has to mapped to the class MonitoredDataSource.      
fakeXADatasource.properties
     $class=atg.service.jdbc.FakeXADataSource
       URL=jdbc:mysql://localhost:3306/employee
       user=atgtest
       password=atgtest
       driver=com.mysql.jdbc.Driver

See also the console output for this.


Console Output

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...