EJB primary keys and legacy database structure


EJB design: EJB primary keys and legacy database structure

  1. EJB primary keys and legacy database structure (1 messages)


    I am aware that a fundamental part of the ejb architecture is that an ejb must be unique, that is there must be a way of identifying one ejb from another to support the many features of distribution, concurrency etc. From the database point of view, this is realised using primary keys, and is enforced at run-time (an exception is raised if duplicates are found based on pks).

    This is fine, but we have a problem with our client in that they do not manage pks as such within their db implementation (db2 btw). It is occuring that we are finding duplicates and these are causing problems with the application. In fact it is quite frustrating as it is seen as an application problem when in reality it is a mismatch between legacy db implementation and our techincal arhictecture. If we realised at the start of the project.....

    Anyway, does anyone have any ideas on how we might be able to manage these type of problems within the application, without having to massage the db directly? This is because as part of our architecture we are taking a nightly snapshot of the data and working on this (large dataset....) and it is already intensive. We are reluctant to add further complications at this level (but of course if it is the only option then so be it...)

    I can guess the amount of worms involved here, but would like to know if anyone out there has dealt with a similar problem.

    Any and all comments appreciated,


  2. Paul,
    When you say that your client "does not manage pks within their db implementation", I assume you mean that there are no checks on the DB2 database side to maintain referential integrity?

    If so, one option would be to write (or rewrite) your SQLs to prevent this duplication from happenning. Essentially, you would have to verify whether a row already exists in the database before you decide whether to update it or to insert a new row. I'm not sure whether this would be applicable to your specific installation.

    Since you have posted this a while back, have you chosen a solution already? If so, I'd like to hear about what option you chose & what were the main criteria which lead you to the decision ...