[Version 5.0.2 and later]Mapping enterprise beans to database tables

Why and when to perform this task

You can map enterprise bean JAR files (EJB modules) to relational database (RDB) tables using the EJB to RDB Mapping wizard of the Assembly Toolkit. The wizard creates EJB to RDB mappings for the following situations:
Existing enterprise bean but no database schema
Top Down mapping generates a default database schema and a mapping from one or more existing enterprise beans.
Existing database schema but no enterprise bean
Bottom Up mapping generates one or more enterprise beans and mappings from an existing database schema.
Existing enterprise bean and database schema
Meet In the Middle mapping matches existing enterprise beans with existing database tables. You can match by name, by name and type, or by neither.

Top-down and meet-in-the-middle mapping support multiple backends, making multiple deployments inside a single EJB module configurable at run time. Bottom-up mapping only supports a single backend. A backend can represent different database vendors, or simply alternative mappings and table qualifiers. If multiple backends exist, then current BackendID needs to be set in the EJB deployment descriptor editor (when working with EJB 2.0 beans). This mapping is used at run time when the JAR is installed on WebSphere Application Server. When deploying EJB 1.1 beans inside an EJB 2.0 project, the EJB 1.1 beans are deployed only once, using the first declared database and type. You specify a Backend ID in an EJB deployment descriptor editor under WebSphere Bindings. The Backend ID determines the persister classes that get loaded at deployment.

Steps for this task

  1. In the J2EE Hierarchy view, right-click the EJB module.
  2. Click Generate > EJB to RDB Mapping.
  3. After the wizard opens, press F1 and select a type of mapping. The online help provides detailed information on generating a mapping.
  4. For EJB 2.0 projects, on the EJB to RGB Mapping page specify whether you want to create a new backend (Top Down) or use an existing backend (Bottom Up or Meet In the Middle) where the schema exists in the backend but without a mapping file. If you previously generated a mapping, you can create and map unmapped elements or open the mapping editor to manually make changes.
    In EJB 2.0, your mapping and schema files make up a backend for EJB 2.0 projects. You can have multiple backend folders for each project; for example, one DB2 and one Oracle backend. The wizard uses one database backend only as the default, but you can define as many as you need.
  5. Follow the instructions in the wizard and in the online help.
  6. Click Finish to generate the mapping.

Related tasks
Assembling applications with the Assembly Toolkit
Related reference
Mapping constraints for databases



Searchable topic ID:   tatk_ejb2rdbmapping
Last updated: Jun 21, 2007 4:55:42 PM CDT    WebSphere Application Server Network Deployment, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tatk_ejb2rdbmapping.html

Library | Support | Terms of Use | Feedback