Java Reference
In-Depth Information
create table advert (
id bigint generated by default as identity (start with 1),
message varchar(255),
title varchar(255),
aduser bigint not null,
primary key (id));
create table category (
id bigint generated by default as identity (start with 1),
title varchar(255),
primary key (id),
unique (title));
create table link_category_advert (
category bigint not null,
advert bigint not null,
primary key (category, advert));
create table message (
id bigint generated by default as identity (start with 1),
message varchar(255),
primary key (id));
alter table advert
add constraint fk_advert_user
foreign key (aduser) references aduser;
alter table link_category_advert
add constraint fk_advert_category
foreign key (category) references category;
alter table link_category_advert
add constraint fk_category_advert
foreign key (advert) references advert;
Note the foreign key constraints and the link table representing the many-to-many
relationship.
Sessions
Chapter 4 will discuss the full life cycle of persistence objects in detail—but you need to
understand the basics of the relationship between the session and the persistence objects if
you are to build even a trivial application in Hibernate.
Search WWH ::




Custom Search