Java Reference
In-Depth Information
public void setId(int id) {
this.id = id;
}
public void setTitle(String title) {
this.title = title;
}
public void setPages(int pages) {
this.pages = pages;
}
public void setPublicationDate(Date publicationDate) {
this.publicationDate = publicationDate;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
public void setAuthors(Set<Author> authors) {
this.authors = authors;
}
// Helpers...
public void addAuthor(Author author) {
authors.add(author);
}
}
Listing 6-35 demonstrates the use of the @NamedQuery , @Embedded , @AttributeOverrides ,
and @AttributeOverride annotations.
Listing 6-35. The Fully Annotated Author Class
package com.hibernatebook.annotations;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
@Entity
@NamedQuery(
name="findAuthorsByName",
query="from Author where name = :author"
)
public class Author {
Search WWH ::




Custom Search