div.collapsecontent{display:block;}

Express (Distributed operating systems), v8.0 > Reference > Command-line utilities > EJB deployment tool > Reference > Limitations of EJB deployment


Problems mapping EJB beans from relational tables with unique constraints

The EJB to relational database (RDB) mapping tools does not support tables with unique constraints.

When performing a bottom-up or meet-in-the-middle mapping, you might encounter the following exception:

org.eclipse.core.runtime.CoreException:
Either the database file is corrupt or sql model files are missing.
Another symptom is when generating EJB deployment code against a table with no primary keys and the table only contains column with unique constraints, you might encounter the following exception:
com.ibm.etools.ejbdeploy.plugin.InternalErrorGenerationException:
Error generating Create query for bean SampleBean (Abstract schema name=SampleBean)
Tip: We can generate EJB deployment code by running the Prepare for Deployment option available in the workbench, or run the ejbdeploy command-line tool from the WAS.

The cause is the EJB to relational database mapping tools can recognize tables with primary and foreign keys; however, the tools cannot identify columns with unique constraints. As a result, the generation of deployment code for EJB beans fails because a container-managed persistence (CMP) bean requires a primary key field.

To workaround defining columns with unique constraints, alter your database table to define at least one of these columns as a primary key. However, converting the unique constraints into primary keys restricts the columns to contain no null values. This is because columns with unique constraints allow null value entries, whereas primary keys ensure that column values are not null. In the workbench after altering the column as a primary key, you can now perform the bottom-up or meet-in-the-middle mapping.

If you cannot alter your database, you can alternatively alter the Physical Data Model (.dbm) files generated by the workbench. The same restriction applies of converting the unique constraints into primary keys, where these columns cannot contain null values.

  1. In the workbench, perform the bottom-up or meeting-in-the middle mapping.

  2. From the database schema, take note of each column with unique constraints.
  3. Define at least one of the CMP field mapping to a column with unique constraints as a primary key:

    1. In the Project Explorer view of the workbench, under the Data Models folder select a CMP field that maps to a column with unique constraints.

    2. In the Properties view, select the Type page. Under the Properties field, enable the Primary Key check box.


Generate a bottom-up mapping
Generate a meet-in-the-middle mapping
Feedback

+

Search Tips   |   Advanced Search