Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this first lesson, you will get a high-level look at some of the important classes of the Hibernate library.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
So we've chosen Hibernate as your ORM,
0:05
and now it's time to get a grasp of the
main components we'll be interacting with.
0:07
Check it out.
0:12
We've already seen this basic
graphic of a Hibernate application.
0:13
If we zoom into the Hibernate component,
we see some important pieces revealed.
0:17
First is the session factory.
0:21
In Hibernate, a session factory
is a fairly heavy weight object
0:24
that contains the relationships between
the application and a database.
0:27
There is usually just one
of these per application.
0:32
It encapsulates all the objects related
to mapping pojos to database tables and
0:35
columns.
0:40
Which is contained in
the metadata sources object.
0:41
A session represents
an interaction with the database
0:45
in which a live connection is established.
0:47
We'll see that before performing any
data operations we'll open a session.
0:50
And when we're done interacting with the
data we'll immediately close the session.
0:55
These objects are lightweight and
therefore, are created as needed.
0:59
A transaction represents a unit of work
that must be performed on the database,
1:03
which might in compass several queries.
1:08
For example, a database transaction
performing a bank account transfer
1:10
might involve deducting a hundred dollars
from one account and adding it to another.
1:14
If adding the hundred dollars
to the second account fails,
1:19
we want to undo the initial deduction.
1:22
Otherwise the hundred dollars vanishes.
1:25
In a transaction we begin the work,
perform all the queries, and
1:28
if they succeed, we commit the
transaction, which finalizes all queries.
1:32
If any part fails, we roll back the
transaction which will reverse each query.
1:37
Pretty powerful stuff.
1:42
And of course, Hibernate supports this.
1:44
Finally, a criteria allows us to query
the database using its mapped pojo class.
1:47
And add restrictions to
further filter those results,
1:52
using methods that translate to
the SQL Like or > or = operators.
1:55
At their most basic level these
restrictions translate to simple or
2:02
compound where clauses.
2:06
All right, now that you've seen some
of the main components of Hibernate.
2:10
Let's dive in.
2:13
Meet me in the next video to start coding.
2:14
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up