Show TOC Start of Content Area

Function documentation Running the JDO Enhancer and Checker Tools  Locate the document in its SAP Library structure

Use

The JDO Enhancer is a bytecode modifier of Java class files that turns plain Java classes into persistence capable ones. Although you have defined the Employee and Department classes as persistence capable by including the persistent fields and creating the JDO metadata, the classes still do not comply thoroughly with the requirements because they do not implement the javax.jdo.spi.PersistenceCapable interface. Therefore, you have to enhance them using the JDO Enhancer, which adds the necessary methods to the classes based on the information in the metadata XML file.

The process of enhancing the classes also involves performing consistency checks. They ensure that there are no discrepancies between the Java model (described in Defining the Persistence Capable Classes and Defining the Object Identity Classes), the JDO model (in Defining the JDO Metadata), the JDBC types (in Creating the Database Tables), and the mapping model (in Defining the O/R Mapping). The JDO Checker is the tool that checks the consistency of the overall model.

Integration

The JDO Enhancer and Checker tools are currently not integrated into the build process of the SAP NetWeaver Developer Studio. Therefore, you have to run the tools manually using a proper build file.

Prerequisites

You must have:

Activities

The most convenient way to run the JDO Enhancer is using the ANT build tool that is integrated into the SAP NetWeaver Developer Studio as a plugin.

       1.      Use the context menu of the GettingStartedJDOWeb project to create a new file called build.xml. Choose to save the file in the GettingStartedJDOWeb main directory.

       2.      The file opens automatically. Enter the following contents:

Example

<project name="GettingStartedWithJDO" default="enhance" basedir="..">

 

  <property name="sourceproject.dir" value="GettingStartedJDOWeb"/>

  <property name="dictproject.dir" value="GettingStartedPersistenceDic"/>

  <property name="src.dir" value="${sourceproject.dir}/source"/>

  <property name="bin.dir" value="${sourceproject.dir}/bin"/>

  <property name="catalog.dir" value="${dictproject.dir}/gen_ddic/dbtables/"/>

 

  <property name="enhancer" value="com.sap.jdo.enhancer.Main"/>

 

  <property name="utility" value="com.sap.jdo.sql.util.JDO"/>

  <property name="tssap" value="C:/Program Files/SAP/JDT/eclipse/plugins"/>

  <property name="jdo" value="${tssap}/com.sap.ide.eclipse.ext.libs.jdo/lib/jdo.jar"/>

  <property name="xml" value="${tssap}/com.tssap.sap.libs.xmltoolkit/lib/sapxmltoolkit.jar"/>

  <property name="jdoutil" value="${tssap}/com.sap.jdo.utils/lib/sapjdoutil.jar"/>

  <property name="dictionary" value="${tssap}/com.sap.dictionary.database/lib/jddi.jar"/>

  <property name="logging" value="${tssap}/com.tssap.sap.libs.logging/lib/logging.jar"/>

  <property name="catalogreader" value="${tssap}/com.sap.opensql/lib/opensqlapi.jar"/>

  <property name="classpath" value="${jdo};${jdoutil};${xml};${logging}"/>

  <property name="classpath.check" value="${classpath};${dictionary};${catalogreader};${bin.dir}"/>

 

  <target name="enhance">

    <antcall target="enhance.Employee"/>

    <antcall target="enhance.Department"/>

  </target>

 

  <target name="check">

    <antcall target="check.Employee"/>

    <antcall target="check.Department"/>

  </target>

 

  <target name="enhance.Employee">

    <java

      fork="yes"

      failonerror="yes"

      classname="${enhancer}"

      classpath="${classpath}">

      <arg line= "-f -d" />

      <arg value= "${bin.dir}" />

      <arg value= "${src.dir}/temp/persistence/gettingstarted/jdo/Employee.jdo" />

      <arg value= "${bin.dir}/temp/persistence/gettingstarted/jdo/Employee.class" />

    </java>

  </target>

 

  <target name="enhance.Department">

    <java

      fork="yes"

      failonerror="yes"

      classname="${enhancer}"

      classpath="${classpath}">

      <arg line= "-f -d" />

      <arg value= "${bin.dir}" />

      <arg value= "${src.dir}/temp/persistence/gettingstarted/jdo/Department.jdo" />

      <arg value= "${bin.dir}/temp/persistence/gettingstarted/jdo/Department.class" />

    </java>

  </target>

 

  <target name="check.Employee">

    <java

      fork="yes"

      failonerror="yes"

      classname="${utility}"

      classpath="${classpath.check}">

      <arg line= "-v -p" />

      <arg value= "${sourceproject.dir}/checker.properties" />

       <arg value= "-c" />

      <arg value= "${catalog.dir}" />

      <arg value= "check" />

      <arg value= "temp/persistence/gettingstarted/jdo/Employee.class" />

    </java>

  </target>

 

  <target name="check.Department">

    <java

      fork="yes"

      failonerror="yes"

      classname="${utility}"

      classpath="${classpath.check}">

      <arg line= "-v -p" />

      <arg value= "${sourceproject.dir}/checker.properties" />

      <arg value= "-c" />

      <arg value= "${catalog.dir}" />

      <arg value= "check" />

      <arg value= "temp/persistence/gettingstarted/jdo/Department.class" />

    </java>

  </target>

 

</project>

 

Caution

The tssap property must point to the installation directory of the SAP NetWeaver Developer Studio.

       3.      Use the context menu of the GettingStartedJDOWeb project to create a new file called checker.properties. Choose to save the file in the GettingStartedJDOWeb main directory. The file opens automatically. Enter the following contents:

Example

com.sap.jdo.sql.mapping.useCatalog=true

com.sap.jdo.sql.mapping.checkConsistency=true

com.sap.jdo.sql.mapping.checkConsistencyDeep=true

 

       4.      In the Java perspective, open the context menu of the build.xml file and choose Run Ant….

       5.      In the Targets tab, choose the option check, in addition to the default target enhance.

       6.      Choose Apply and then Run. The output of the process is printed in the console of the Developer Studio.

 

Result

The classes now implement the javax.jdo.spi.PersistenceCapable interface. The next step is implementing the business logic.

 

 

 

End of Content Area