CHAPTER 2 Starting a project The HibernateToolTask definition for Ant is the same as before. We assume that you ll reuse most of the build file introduced in previous sections, and that references such as project.classpath are the same. The task is set with WORKDIR/src as the default destination directory for all generated artifacts. A is a Hibernate tool configuration that can connect to a database via JDBC and read the JDBC metadata from the database catalog. You usually configure it with two options: database connection settings (the properties file) and an optional reverse-engineering customization file. The metadata produced by the tool configuration is then fed to exporters. The example Ant target names two such exporters: the hbm2hbmxml exporter, as you can guess from its name, takes Hibernate metadata (hbm) from a configuration, and generates Hibernate XML mapping files; the second exporter can prepare a hibernate.cfg.xml file that lists all the generated XML mapping files. Before we talk about these and various other exporters, let s spend a minute on the reverse-engineering customization file and what you can do with it. 2.3.2 Customizing reverse engineering JDBC metadata that is, the information you can read from a database about itself via JDBC often isn t sufficient to create a perfect XML mapping file, let alone Java application code. The opposite may also be true: Your database may contain information that you want to ignore (such as particular tables or columns) or that you wish to transform with nondefault strategies. You can customize the reverse- engineering procedure with a reverse-engineering configuration file, which uses an XML syntax. Let s assume that you re reverse-engineering the Hello World database you created earlier in this chapter, with its single MESSAGES table and only a few columns. With a helloworld.reveng.xml file, as shown in listing 2.17, you can customize this reverse engineering. Listing 2.17 Configuration for customized reverse engineering B C
D
E
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.
This entry was posted
on Wednesday, October 31st, 2007 at 11:16 pm and is filed under PHP5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.