Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2) Part No. B15505-01 |
|
![]() Previous |
![]() Next |
If you have defined your database columns with a constraint, such as NOT NULL, you may encounter an error after the ejbCreate
method. An INSERT
is performed after the ejbCreate
method; thus, if any field in the database row was left null, the constraint raises a database table constraint violation. This occurs mostly with foreign keys as they cannot be assigned until the ejbPostCreate
method. In order to avoid this problem, you must relax the constraint on the field in question.
You can relax the database constraints by redefining the offending column to DEFERRABLE. If you relax the constraint, you will have time to set the database field before the transaction commits and avoid the database constraint violation.
The following shows how to create a deferrable constraint for the TEST
table:
create table test (test varchar2(10) not null INITIALLY DEFERRED DEFERRABLE )