Web hosting account - Integrating legacy databases Fortunately, it s often straightforward to
Integrating legacy databases Fortunately, it s often straightforward to clean up such a schema by refactoring foreign keys to reference primary keys if you can make changes to the database that don t disturb other applications sharing the data. This completes our exploration of natural, composite, and foreign key-related problems you may have to deal with when you try to map a legacy schema. Let s move on to other interesting special mapping strategies. Sometimes you can t make any changes to a legacy database not even creating tables or views. Hibernate can map classes, properties, and even parts of associations to a simple SQL statement or expression. We call these kinds of mappings formula mappings. 8.1.2 Arbitrary join conditions with formulas Mapping a Java artifact to an SQL expression is useful for more than integrating a legacy schema. You created two formula mappings already: The first, Using derived properties, in chapter 4, section 4.4.1, was a simple derived read-only property mapping. The second formula calculated the discriminator in an inheritance mapping; see chapter 5, section 5.1.3, Table per class hierarchy. You ll now apply formulas for a more exotic purposes. Keep in mind that some of the mappings you ll see now are complex, and you may be better prepared to understand them after reading all the chapters in part 2 of this book. Understanding the use case You now map a literal join condition between two entities. This sounds more com plex than it is in practice. Look at the two classes shown in figure 8.2. A particular Item may have several Bids this is a one-to-many association. But it isn t the only association between the two classes; the other, a unidirectional Figure 8.2 A single-association that references an instance in a many-association
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.