Disney web site - CHAPTER 3 Domain models and metadata Creating the

CHAPTER 3 Domain models and metadata Creating the Hibernate XML mapping document with XDoclet is straightforward; instead of writing it by hand, you mark up the Java source code of your persistent class with custom Javadoc tags, as shown in listing 3.5. Listing 3.5 Using XDoclet tags to mark up Java classes with mapping metadata /** * The Category class of the CaveatEmptor auction site domain model. * * @hibernate.class * table=”CATEGORY” */ public class Category { … /** * @hibernate.id * generator-class=”native” * column=”CATEGORY_ID” */ public Long getId() { return id; } … /** * @hibernate.property */ public String getName() { return name; } … } With the annotated class in place and an Ant task ready, you can automatically generate the same XML document shown in the previous section (listing 3.4). The downside to XDoclet is that it requires another build step. Most large Java projects are using Ant already, so this is usually a nonissue. Arguably, XDoclet mappings are less configurable at deployment time; but there is nothing stopping you from hand-editing the generated XML before deployment, so this is probably not a significant objection. Finally, support for XDoclet tag validation may not be available in your development environment. However, the latest IDEs support at least autocompletion of tag names. We won t cover XDoclet in this book, but you can find examples on the Hibernate website.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.