Java Reference
In-Depth Information
Adding persistence to our application
In order to persist data, JPA needs a relational database; we will use the MySQL data-
base, which is pretty popular among developers and can be downloaded for free from
http://dev.mysql.com/downloads . It is recommended to download the latest stable re-
lease of MySQL 5.x and install it using the simple installation wizard.
Setting up the database
We will create a database named appstore ; we will then add a user named jboss
and assign him all privileges on the schemas.
Open a shell under the bin folder of your MySQL installation and launch the execut-
able mysql . Once logged in, execute the following commands:
CREATE DATABASE ticketsystem;
USE ticketsystem;
CREATE USER 'jboss'@'localhost' IDENTIFIED BY
'jboss';
GRANT ALL PRIVILEGES ON ticketsystem.* TO
'jboss'@'localhost' WITH GRANT OPTION;
Our simple schema will be made up of two tables—the SEAT table, which contains
the list of all available seats in the theatre and the SEAT_TYPE table, which is used to
categorize the seat types. The two tables are in a 1-n relationship and the SEAT table
hosts a foreign key ( seat_id ) that relates to the ID of the SEAT_TYPE table:
The schema is as follows:
Search WWH ::




Custom Search