,
VERSION INT NOT NULL DEFAULT 0
,
UNIQUE UQ_CONTACT_TEL_DETAIL_1 (CONTACT_ID, TEL_TYPE)
,
PRIMARY KEY (ID)
,
CONSTRAINT FK_CONTACT_TEL_DETAIL_1 FOREIGN KEY (CONTACT_ID)
REFERENCES CONTACT (ID)
);
CREATE TABLE CONTACT_HOBBY_DETAIL (
CONTACT_ID INT NOT NULL
, HOBBY_ID VARCHAR(20) NOT NULL
, PRIMARY KEY (CONTACT_ID, HOBBY_ID)
, CONSTRAINT FK_CONTACT_HOBBY_DETAIL_1 FOREIGN KEY (CONTACT_ID)
REFERENCES CONTACT (ID) ON DELETE CASCADE
, CONSTRAINT FK_CONTACT_HOBBY_DETAIL_2 FOREIGN KEY (HOBBY_ID)
REFERENCES HOBBY (HOBBY_ID)
);
Listing 9-3. Data Population Script(test-data.sql)
insert into contact (first_name, last_name, birth_date) values
('Clarence', 'Ho', '1980-07-30');
insert into contact (first_name, last_name, birth_date) values
('Scott', 'Tiger', '1990-11-02');
insert into contact (first_name, last_name, birth_date) values
('John', 'Smith', '1964-02-28');
insert into contact_tel_detail (contact_id, tel_type, tel_number) values
(1, 'Mobile', '1234567890');
insert into contact_tel_detail (contact_id, tel_type, tel_number) values
(1, 'Home', '1234567890');
insert into contact_tel_detail (contact_id, tel_type, tel_number) values
(2, 'Home', '1234567890');
insert
into
hobby
(hobby_id)
values
('Swimming');
insert
into
hobby
(hobby_id)
values
('Jogging');
insert
into
hobby
(hobby_id)
values
('Programming');
insert
into
hobby
(hobby_id)
values
('Movies');
insert
into
hobby
(hobby_id)
values
('Reading');
insert into contact_hobby_detail(contact_id, hobby_id) values (1, 'Swimming');
insert into contact_hobby_detail(contact_id, hobby_id) values (1, 'Movies');
insert into contact_hobby_detail(contact_id, hobby_id) values (2, 'Swimming');
Configuring Hibernate SessionFactory
As mentioned earlier in this chapter, the core concept of Hibernate is based on the Session interface,
which is obtained from the SessionFactory. Spring provides a number of classes to support the
configuration of Hibernate's session factory as a Spring bean with the desired properties. Since we are
going to use the annotation style, we will use the class AnnotationSessionFactoryBean. Listing 9-4 shows
the corresponding XML configuration file (app-context.xml).
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home