Generating code from an SDO genmodel file

Prerequisites:

To generate the code from an SDO genmodel file:

  1. Start WebSphere Commerce Developer.

  2. Open the J2EE perspective.

  3. Open your MyServiceModule-DataObjects/ecore folder.

  4. Double-click the MyServiceModule.genmodel file to open it.

  5. Notice that the MyServiceModule namespace has picked up the name "Datatypes" (generated by default). Select the Datatypes element, then right-click and select Properties.

  6. In the Properties view, change the prefix from Datatypes to the factory name that you want. For example, MyServiceModule.

  7. From the genmodel file, click the root of the tree (the highest node in the order tree from the image above). Right-click, and select Set SDO Defaults and save it.

    If you do not perform this step, then your project classpath will be corrupted when you generate the code.

  8. Now, select the schema namespace entry for your component. Right-click, and select Generate Model Code.

  9. in the src directory of your DataObjects project, you can now see the generated SDO files for this namespace.

    Three packages are generated:

    • The datatypes directory that provides interfaces to all of your SDO objects

    • A datatypes.impl directory that provides the static SDO EMF implementation

    • A datatypes.util directory that provides the factory and resource helper classes

Generating SDO code may break functionality in your DataObjects project by removing entries from your Java build path (in the Projects and Order and Export tabs). The following steps may be required to correct your settings:

  1. Right-click on the source project and select Properties.

  2. Click Java Build Path and then the Projects tab. Ensure that the projects you require for compilation are selected.

  3. Click on the Order and Export tab and ensure that the projects you require for compilation are checked

  4. Click OK.

Related concepts

WebSphere Commerce services
WebSphere Commerce service module
Service Data Objects (SDO)

Related tasks

Create the SDO genmodel file
Updating Service Data Objects