Cedant web hosting - CHAPTER 8 Legacy databases and custom SQL import

CHAPTER 8 Legacy databases and custom SQL import org.hibernate.dialect.Dialect; import org.hibernate.engine.Mapping; public class CustomDDLExtension extends AbstractAuxiliaryDatabaseObject { public CustomDDLExtension() { addDialectScope(”org.hibernate.dialect.Oracle9Dialect”); } public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema) { return “[CREATE statement]”; } public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) { return “[DROP statement]”; } } You can add dialect scopes programmatically and even access some mapping information in the sqlCreateString() and sqlDropString() methods. This gives you a lot of flexibility regarding how you create and write your DDL statements. You have to enable this custom class in your mapping metadata: Additional dialect scopes are cumulative; the previous examples all apply to two dialects. 8.4 Summary In this chapter, we looked at issues that you may run into when you have to deal with a legacy database schema. Natural keys, composite keys, and foreign keys are often inconvenient and need to be mapped with extra care. Hibernate also offers formulas, little SQL expressions in your mapping file, that can help you to deal with a legacy schema you can t change. Usually, you also rely on Hibernate s automatically generated SQL for all create, read, update, and delete operations in your application. In this chapter,
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.