100 CHAPTER 6 n (Web site traffic) MAPPING WITH ANNOTATIONS CHAPTER

100 CHAPTER 6 n MAPPING WITH ANNOTATIONS CHAPTER 6 n MAPPING WITH ANNOTATIONS The set of example classes represents a publisher s catalog of books. You ll start with a single class, Book, which has no annotations or mapping information. For this example s purposes, you do not have an existing database schema to work with, so you need to define your relational database schema as you go. At the beginning of the example, the Book class is very simple. It has two fields, title and pages; and an identifier, id, which is an integer. The title is a String object, and pages is an integer. As we go through this example, we will add annotations, fields, and methods to the Book class. The complete source code listing for the Book and Author classes is given at the end of this chapter the source files for the rest are available in the source code download for this chapter on the Apress web site (www.apress.com). Listing 6-3 gives the source code of the Book class, in its unannotated form, as a starting point for the example. Listing 6-3. The Book Class, Unannotated package com.hibernatebook.annotations; public class Book { private String title; private int pages; private int id; // Getters… public int getId() { return id; } public String getTitle() { return title; } public int getPages() { return pages; } // Setters… public void setId(int id) { this.id = id; } public void setTitle(String title) { this.title = title; }
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

Leave a Reply