Reverse engineering a legacy database The reads all Hibernate XML mapping files, and the exporter produces Java source code with the default strategy. Customizing entity class generation By default, hbm2java generates a simple entity class for each mapped entity. The class implements the Serializable marker interface, and it has accessor methods for all properties and the required constructor. All attributes of the class have private visibility for fields, although you can change that behavior with the element and attributes in the XML mapping files. The first change to the default reverse engineering behavior you make is to restrict the visibility scope for the Message s attributes. By default, all accessor methods are generated with public visibility. Let s say that Message objects are immutable; you wouldn t expose the setter methods on the public interface, but only the getter methods. Instead of enhancing the mapping of each property with a element, you can declare a meta-attribute at the class level, thus applying the setting to all properties in that class: private … The scope-set attribute defines the visibility of property setter methods. The hbm2java exporter also accepts meta-attributes on the next higher-level, in the root element, which are then applied to all classes mapped in the XML file. You can also add fine-grained meta-attributes to single property, collection, or component mappings. One (albeit small) improvement of the generated entity class is the inclusion of the text of the Message in the output of the generated toString() method. The text is a good visual control element in the log output of the application. You can change the mapping of Message to include it in the generated code:
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
This entry was posted
on Friday, November 2nd, 2007 at 11:33 am 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.