Java Reference
In-Depth Information
The DAO maps application calls to the persistence mechanism and provides specific data
operations without exposing details of the database. The DAO interface abstracts the
implementation details of accessing the data from the client (application object) and provides the
domain-specific objects that the client (application object) needs.
First you need to create the domain-specific classes for the Java object representations of the
database tables. Listings 1-4, 1-5, and 1-6 show the Book , Author , and Category domain classes,
respectively.
Listing 1-4. Model: Category
package com.apress.books.model;
public class Category {
private Long id;
private String categoryDescription;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCategoryDescription() {
returncategoryDescription;
}
public void setCategoryDescription(String categoryDescription) {
this.categoryDescription = categoryDescription;
}
public String toString() {
return "Category - Id: " + id + ", Category Description: "
+ categoryDescription;
}
}
Listing 1-5. Model: Book
package com.apress.books.model;
import java.util.List;
import com.apress.books.model.Author;
public class Book {
private Long id;
private Long categoryId;
private String bookTitle;
Search WWH ::




Custom Search