I have 2 entity beans, say ZipCode and City. ZipCode attributes are pk, description, cityPK while City attributes are pk and description. In the database schema ZipCode table there is an unique constrait for (description, cityPK) pair while, in the abstract schema, cityPK is a CMR field. The ZipCode EB uses ejbCreate(pk, description, cityPK) to set pk and description and ejbPostCreate(pk, description, cityPK) to set cityPK.
A session bean exposes saveZipCode(ZipCode zip) method which throws a customize Exception, say BackEndException. BackEndException may be specialized according to the error catch during a ZipCode creation (ie Unique Key Violation, PK already present, etc) The body of saveZipCode(ZipCode zip) is: