EJBDEPLOY relationships - troubleshooting tips
(ZOS) DB2 for z/OS v7.x
Problems might exist when EJBDeploy creates a data relationship in DB2 for z/OS v7.x. EJBDeploy creates a table with a composite of the two primary keys of the EJBs related to each other. If the composite keys are larger than 254 characters, DB2 for z/OS V7.x does not accept this relationship and the following error can occur:
DSNT408I SQLCODE = -613, ERROR: THE PRIMARY KEY OR A UNIQUE CONSTRAINT IS TOO LONG OR HAS TOO MANY COLUMNS DSNT418I SQLSTATE = 54008 SQLSTATE RETURN CODE
This problem can be seen when the primary keys created for the two related beans have primary keys that are strings. This results in the composite being made up of 2 varchar(250) primary keys for a total of 500, which is greater than 254 maximum in DB2 for z/OS version 7.x.
Things to consider when utilizing top-down mappings to ensure we do not experience this problem:
- Top-down mappings are a guideline and must be reviewed with the DBA.
- Schemas created top-down by EJBDeploy are designed only for testing, and as a guideline for the actual schema required. The use of the meet-in-the-middle mapping does not present this problem.
- The composite key constraint problem is not experienced when using DB2 V8, which has 2K maximum key lengths.
EJBDEPLOY_JVM_ARGS:
Set the EJBDEPLOY_JVM_ARGS property to override Java virtual machine (JVM) options passed to the code that deploys EJBs (ejbdeploy.sh). Set this property in one of the following locations: deploymentmanager/bin/setupCmdLine.sh or appServerHome/bin/setupCmdLine.sh
For example, the following specifies that unqualifed SQL should be generated:
export EJBDEPLOY_JVM_ARGS="-DEJBDEPLOY_GENERATE_UNQUALIFIED_SQL=true"
The converter that is defined for the primary key is not invoked on its foreign key value
The mapping for primary key fields to database columns may use a converter to transform the key values. If a container-managed persistence (CMP) bean uses a converter to map its primary key, and that bean has a relationship where the bean at the other end holds a foreign key, the mapping for the foreign key will not use the converter.
The following errors might occur, indicating that the converter defined for the primary key is not invoked on its foreign key value. During the run of the ejbDeploy command, we receive the following message:
No type mapping defined for Java datatype1 to Database datatype2
During run time, the application does not find the CMP bean at the other end of the relationship.
To work around this limitation, define our own foreign key in the database table, and create a mapping that uses the same converter as defined for the primary key on the enterprise beans at the other end of its relationship.
Related:
Troubleshoot and support Assembling EJB modules