Apache Jakarta and Beyond: A Java Programmeramp;#039;s Introduction [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Apache Jakarta and Beyond: A Java Programmeramp;#039;s Introduction [Electronic resources] - نسخه متنی

Larne Pekowsky

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







10.8. Related Tools


Although it is often easiest to define the tables, beans, and mapping file at the same time, there are a number of tools available that will aid in the creation of some of these from the information contained in the others. Of particular note are the following four tools that are designed to generate classes and a mapping file from an existing database:

  • reverse-db, included with OJB

  • rdbs2j, a tool developed separately from OJB and available from http://sourceforge.net/projects/rdbs2j

  • reverse-db2, an update of reverse-db

  • the Impart plugin for Eclipse, available from http://www.impart.ch/download


Unfortunately, at the time of this writing none of these tools work. reverse-db cannot read table information from either hsqldb or mysql, although it may work with other databases. rdbs2j is in a beta release, but all the program text is in German (the program itself may work perfectly well for those who can read the menu items and dialogs). reverse-db2 seems to be an early effort, with no functionality implemented yet beyond the ability to explore the database.

The fourth option, the Eclipse plugin from Impart, worked with Eclipse 2.1.5 but does not work with 3.0.0. This will likely be fixed in the near future as 3.0.0 matures. For the time being, the following section describes usage of this plugin with 2.1.5.

Installation is a simple matter of unzipping the downloaded file in the Eclipse "plugins" directory and then restarting Eclipse.

This plugin requires a configuration file called "ImpartOJBGenerator.properties" to be placed in the home directory under Unix variants or C:\Documents and Settings\login_name under Windows. This file contains the typical set of database connection information as well as mappings for JDBC types. See the readme file that accompanies the plugin for more details.

The new features that this plug adds to Eclipse are accessible from the "Window" menu. Select "Show view" then "Other . . . " and the pop-up shown in Figure 10.4 will be displayed.


Figure 10.4. The Eclipse other view selector.

Selecting the "OJB DB Tree" will bring up a database browser window. By default this Window will occupy the space usually taken by the console or task list seen in previous Eclipse screenshots. In Figure 10.5 this window has been expanded to become the main window, and the ALBUM table has been expanded. All the tables that begin with the prefix OJB_ are the internal OJB tables mentioned in the discussion of the "repository_internal.xml" mapping file.


Figure 10.5. The OJB DB Tree view.

There are three icons on the right of the window toolbar. The first will reload the table data from the database. The second will generate Java files for all selected tables. The third will generate both "repository_database.xml" and "repository_user.xml" mapping files. It is important when generating such a file to ensure that the OJB internal tables are not selected because the generated mappings will conflict with those in "repository_internal.xml."

The generated code and mapping files have some slight differences from those that have been used in this chapter. The convention used until now is that underscores in names of tables and fields are omitted and the following letter capitalized in the corresponding class and property names. Impart leaves names as they appear in the database, capitalizing only the first letter.

Impart is able to detect primary keys, and these will be correctly marked in the mapping file. Impart is not able to detect foreign key relationships, so no collections will be placed in the generated class files or mapping files. These will need to be added by hand. Even with these shortcomings, Impart is a useful tool that can save a great deal of tedious typing.


/ 207