public class Book extends Model
package app.models;
import jedi.db.models.CharField;
import jedi.db.models.ForeignKeyField;
import jedi.db.models.Manager;
import jedi.db.models.ManyToManyField;
import jedi.db.models.Model;
import jedi.db.models.QuerySet;
import jedi.db.models.Table;
@Table(name = "books", engine = "InnoDB", charset = "utf8", comment = "Table of books")
public class Book extends Model {
// Atributes
private static final long serialVersionUID = 9076408430303339094L;
@CharField(max_length = 30, required = true, unique = true, comment = "This field stores the book\\'s title.")
private String title;
@ManyToManyField
private QuerySet<Author> authors;
@ForeignKeyField
private Publisher publisher;
@CharField(max_length = 15, required = true)
private String publicationDate;
public static Manager objects = new Manager(Book.class);
// Constructors
public Book() {
authors = new QuerySet<Author>();
publisher = new Publisher();
}
public Book(String title, QuerySet<Author> authors, String publicationDate) {
this();
this.title = title;
this.authors = authors;
this.publicationDate = publicationDate;
}
// Getters
public String getTitle() {
return title;
}
public QuerySet<Author> getAuthors() {
return authors;
}
public Publisher getPublisher() {
return publisher;
}
public String getPublicationDate() {
return publicationDate;
}
// Setters
public void setTitle(String title) {
this.title = title;
}
public void setAuthors(QuerySet<Author> authors) {
this.authors = authors;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
public void setPublicationDate(String publicationDate) {
this.publicationDate = publicationDate;
}
}
Long
,
String
,
CharField
,
ForeignKeyField
,
Manager
,
ManyToManyField
,
Model
,
Table
Modifier and Type | Field and Description |
---|---|
private QuerySet<Author> |
authors
Autores do livro.
|
static Manager |
objects
Gerenciador de consultas a objetos dessa classe persistidos
em banco de dados.
|
private String |
publicationDate
Data de publicação do livro.
|
private Publisher |
publisher
Editora do livro.
|
private static long |
serialVersionUID
Número de versão da classe.
|
private String |
title
Título do livro.
|
id, isPersisted, tableName
Constructor and Description |
---|
Book()
Construtor padrão.
|
Book(String title,
QuerySet<Author> authors,
String publicationDate)
Construtor que recebe o título, os autores e a
data de publicação do livro.
|
Modifier and Type | Method and Description |
---|---|
QuerySet<Author> |
getAuthors()
Retorna os autores do livro.
|
String |
getPublicationDate()
Retorna a data de publicação do livro.
|
Publisher |
getPublisher()
Retorna a editora do livro.
|
String |
getTitle()
Retorna o título do livro.
|
void |
setAuthors(QuerySet<Author> authors)
Define os autores do livro.
|
void |
setPublicationDate(String publicationDate)
Define a data de publicação do livro.
|
void |
setPublisher(Publisher publisher)
Define a editora do livro.
|
void |
setTitle(String title)
Define o título do livro.
|
as, autoCloseConnection, autoCloseConnection, compareTo, connection, delete, equals, get, getAutoCloseConnection, getId, getTableName, id, id, insert, isPersisted, isPersisted, save, save, set, setAutoCloseConnection, setConnection, setId, setTableName, tableName, tableName, toCSV, toExtenseXML, toExtenseXML, toJSON, toJSON, toString, toString, toXML, toXML, update
private static final long serialVersionUID
Long
,
Constant Field Valuesprivate QuerySet<Author> authors
ManyToManyField
,
QuerySet
,
Author
private Publisher publisher
ForeignKeyField
,
Publisher
private String publicationDate
public Book()
public String getTitle()
String
public Publisher getPublisher()
Publisher
public String getPublicationDate()
String
public void setTitle(String title)
title
- o título do livroString
public void setPublisher(Publisher publisher)
publisher
- a editora do livroPublisher