34. class Book {
String title
String author
Boolean paperback
}
Book.findAllPaperbackByAuthor(" ")
Book.findAllNotPaperbackByAuthor(" ")
35. class Person {
String name
static hasOne = [address: Address]
}
create table address (
class Address { id bigint ... ,
String street version bigint not null,
String postCode person_id bigint not null,
street varchar(255) not null,
Person person post_code varchar(255) not null,
} primary key (id),
unique (person_id))
create table person (
id bigint ... ,
version bigint not null,
name varchar(255) not null,
primary key (id)
)
36. class Publication {
String title
Date datePublished
static namedQueries = {
recentPublications {
def now = new Date()
gt 'datePublished',now-365
}
publicationsWithBookInTitle {
like 'title','%Book%'
}
}
}
def list = Publication.recentPublications.list()
def list = Publication.recentPublications.list(
max: 10, offset: 5)
Publication.recentPublications.count()