Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Configuring Giflib for Hibernate3:03 with Chris Ramacciotti
This video begins our configuration of Hibernate for use in Giflib. As a first step, we need to add a few dependencies to our Gradle build file, including the Spring ORM, Apache DBCP, and H2 Database libraries.
Git Command to Sync Your Code to the Start of this Video
git checkout -f s1v4
Using Github With This Course
You can complete this course entirely using code created by you on your local machine. However, if you choose to use the code I've made available to you, you have two options:
- Use the project files linked at the bottom of this page, or
- Use the Github repository I've made available (recommended)
If you choose the recommended option of using the Github repository, it can be found at
To utilize Github with this course, you can download the Github desktop client for your system or use the command line interface provided with Git.
Clone this repository to your machine using the Github desktop client, or using the following command:
git clone email@example.com:treehouse/giflib-hibernate.git
To update your local repository to match a video's starting point, you can use the
git checkout command in combination with the stage and video number. For example, to update your local repository to match the starting point of Stage 5, Video 4, you'd use the following:
git checkout -f s5v4
Notice the use of the -f option. This forces Git to override all local changes, so be aware: this will cause any changes you made to be lost.
So you've scrolled through the gif flip code and dusted off the old Spring hat.
I think it's time to dig into our app and start making some changes.
We'll begin by discussing how to configure our Spring app to use Hibernate.
Here we go.
The first order of business in our configuration, in this app,
is to add the necessary dependencies.
We have four that we're going to add.
First is a dependency on Spring ORM.
This allows us to integrate an object-relational mapping library
seamlessly into our Spring app.
So I'll add that next.
We'll need data compile time.
The group name is org.springframework.
The ID is spring-orm, and
the version is 4.2.5.RELEASE.
Then next will be the ORM implementation we're using,
which in our course is Hibernate.
So there again, we'll need it as a compile time dependency,
org.hibernate is the group name.
hibernate-core is the ID,
and we're going to use 5.1.0.Final.
The third is a library called, DBCP from Apache.
DBCP stands for Database Connection Pooling and allows our app to
reuse database connection objects, since those objects take some time to construct
being that they're dependent on establishing a connection to the database.
So here's the dependency for DBCP.
We'll need that also at compile time.
The group name is org.apache.tomcat.
And the ID is tomcat-dbcp,
the version number 8.0.32.
Finally, let's add our database provider which will be H2.
To remind you, H2 is a nice tool because it allows for
a range of connectivity options.
From in memory databases that are created and destroyed, and held entirely in memory
from the time you run your app to the time you kill your app, to portable single file
databases that don't require you to start a database server, and finally to full
server based databases, which do require you to start a database server.
You've seen the file based mode in Hibernate Basics.
In this course, we'll experiment with server mode.
So let's add that dependency now.
Again, this is a compile time database.
The group name is com.h2database.
The ID is h2, and the version is 1.4.191.
Now, let's pop open the Gradle Tool window and refresh our dependencies,
to pull down those jars and add them to the class path.
You'll hit that refresh button there, and at the bottom you should see some
messages that indicate that dependencies are being resolved and downloaded.
And with those libraries added, we've wrapped up our Gradle build file.
Now that said, we still have some work to do in configuring our data source in
We will tackle these items next.
You need to sign up for Treehouse in order to download course files.Sign up