CHAPTER 8 Legacy databases and (Disney web site) custom SQL more
Wednesday, February 20th, 2008CHAPTER 8 Legacy databases and custom SQL more often relates to the implementation of the logical data model as a physical database schema. If you accept this observation, you ll see that the kinds of problems that require schema changes are those that necessitate addition of new entities, refactoring of existing entities, addition of new attributes to existing entities, and modification to the associations between entities. The problems that can be solved without schema changes usually involve inconvenient table or column definitions for a particular entity. In this section, we ll concentrate on these kinds of problems. We assume that you ve tried to reverse-engineer your existing schema with the Hibernate toolset, as described in chapter 2, section 2.3, Reverse engineering a legacy database. The concepts and solutions discussed in the following sections assume that you have basic object/relational mapping in place and that you need to make additional changes to get it working. Alternatively, you can try to write the mapping completely by hand without the reverse-engineering tools. Let s start with the most obvious problem: legacy primary keys. 8.1.1 Handling primary keys We ve already mentioned that we think natural primary keys can be a bad idea. Natural keys often make it difficult to refactor the data model when business requirements change. They may even, in extreme cases, impact performance. Unfortunately, many legacy schemas use (natural) composite keys heavily and, for the reason we discourage the use of composite keys, it may be difficult to change the legacy schema to use noncomposite natural or surrogate keys. Therefore, Hibernate supports the use of natural keys. If the natural key is a composite key, support is via the
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.