Object/relational mapping metadata Whether you use (Web hosting ratings) XML files,

Object/relational mapping metadata Whether you use XML files, JDK 5.0 annotations, or XDoclet, you ll often notice that you have to duplicate metadata in several places. In other words, you need to add global information that is applicable to more than one property, more than one persistent class, or even the whole application. 3.3.4 Handling global metadata Consider the following situation: All of your domain model persistent classes are in the same package. However, you have to specify class names fully qualified, including the package, in every XML mapping file. It would be a lot easier to declare the package name once and then use only the short persistent class name. Or, instead of enabling direct field access for every single property through the access=”field” mapping attribute, you d rather use a single switch to enable field access for all properties. Class- or package-scoped metadata would be much more convenient. Some metadata is valid for the whole application. For example, query strings can be externalized to metadata and called by a globally unique name in the application code. Similarly, a query usually isn t related to a particular class, and sometimes not even to a particular package. Other application-scoped metadata includes user-defined mapping types (converters) and data filter (dynamic view) definitions. Let s walk through some examples of global metadata in Hibernate XML mappings and JDK 5.0 annotations. Global XML mapping metadata If you check the XML mapping DTD, you ll see that the root element has global options that are applied to the class mapping(s) inside it some of these options are shown in the following example: The schema attribute enables a database schema prefix, AUCTION, used by Hibernate for all SQL statements generated for the mapped classes. By setting default- lazy to false, you enable default outer-join fetching for some class associations, a
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.