At 10:09  24/07/00 -0400, you wrote:
>In theory it would be nice to enforce integrity constraints in only one place.
>In practice, you'll probably have to compromise. Here are the reasons we
>had to
>implement a hybrid solution.
>
>1) Some integrity checks are much faster if implemented in the DBMS. For
>instance, unique constraints would require an extra DB statement execution if
>implemented in EJB instead of DBMS.

Absolutely. You also wouldn't want to have the extra overhead for something
that you believe should only occur rarely (if at all).


>2) There is no standard exception (at least in practice) thrown by different
>JDBC drivers and DBMSs for the same type of constraint. If you need to write
>beans that support multiple drivers/DBMSs then you're going to end up with
>a lot
>of messy code to in order to report an understandable error to the user.

Spot on here. The idea should be that JDBC and EJB should remove DBMS
variants from the equation. That said, it would be nice if JDBC and EJB
could standardise on these exceptions via a mapping of some sort.

>3) Some DBMS cannot handle complex foreign key constraints. For instance, we
>have some dependent objects (email & phone numbers) that can be attached to
>various tables. This occurs because we chose to map various subclasses of
>people
>and organizations to different tables. Stored procedures or triggers are
>required for the logic needed to implement referential integrity for this case
>in the DBMS. It much easier to implement this kind of constraint in the Entity
>beans.

Yes, these types of constraints as well as those where a row may have
effective and expiry dates and 'conditional' RI for the parent ie. parent
row must also be effective within the effective and expiry dates. The only
problem is that for performance reasons it may be better to place these
kinds of checks as stored procedures or triggers as it may save substantial
over the wire SQL calls. Naturally this may reduce the portability of the
app as the DBMS code could be fairly specific unless coded in Java.


Cheers,

Eddie

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to