Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
An ORM Tool
Hibernate Implementation Workshop
Who should Attend
Knowledge of SQL (Oracle / MySQL)
Java developers who need to explore alternative methods of
persistence in Java applications.
Saving data to a storage is called persistence.
Programming with JDBC
Environment Required
Oracle 10g XE / MySQL
Java Development Environment (JDK 5 or above)
Hibernate Framework Libraries
NetBeans 6 or above an IDE
Registration Case Study
To demonstrate the different steps involved in a
Hibernate application
We will develop an application that can add, update,
delete or search a user in the database.
As discussed, we can use Oracle database for storing the
user information.
Setting up Database
Oracle 10g XE is a free Relational Database
Management System based on the Structured Query
Language (SQL).
It is very fast reliable and flexible Database
Management System based on relation model that is
developed to manage large volumes of data at very high
speed with security.
Oracle 10g XE can be used for variety of applications
but it is one of the most popular RDBMS used for the
web applications on the Internet.
Install Oracle 10g XE Database
You can go to http://www.oracle.com/ and download and
install.
Setting Up Database Contd..,
Create an User “cec” with password “cec”
We’ll use a single table ‘users’ to store the user
information with the following fields.
The syntax for the oracle is given below.
CREATE TABLE USERS(
USER_ID NUMBER PRIMARY KEY,
FIRST_NAME VARCHAR2(20),
LAST_NAME VARCHAR2(20),
AGE NUMBER,
EMAIL VARCHAR(40)
);
Working with IDE
NetBeans
is an open-source integrated development environment written
entirely in Java.
NetBeans IDE supports development of all Java application
types (Java SE, web, EJB and mobile applications).
Download from http://java.sun.com
Creating a Project
Understanding Directory Structure
Compiling
Running a Project
Persistence in OO Applications
When an application is developed, a major portion of
that application involves the creation and maintenance
of the data to store and retrieve from the database.
Persistence: The ability of an object to remain in
existence past the lifetime of the program that creates it.
The state of an object can be stored to a disc, and an
object with the same state can be re-created at some
point in future.
Persistence Implementation
There are various ways the persistence layer can be
implemented:
Hard-coding with SQL/JDBC
user.setUserId(1);
user = manager.getUser(user);
System.out.println("Name >>> " +
user.getFirstName() + " " + user.getLastName());
Problems with JDBC Code
Too many SQL statements
Using JDBC means you can execute any kind of SQL statements.