Spring with Hibernate Course

0
Join & Subscribe
Treehouse
Free Trial Available
English
3-4 hours worth of material
selfpaced

Overview

Using Hibernate to manage relational data in a Spring web application is not only an extremely powerful and scalable approach, but also widely used. In this course, we'll add a database to an animated GIF library, and discuss some more powerful features of Spring and Thymeleaf, such as HTML forms, file uploading, form validation, and flash messaging.

What you'll learn

  • Spring
  • Hibernate
  • ORM
  • Post-Redirect-Get

Integrating Hibernate with Spring

As a first step toward using Hibernate in a Spring application, we first discuss how to configure a Spring app to include Hibernate for data management. We'll add the necessary dependencies and configuration code so that a Hibernate SessionFactory can be autowired into Spring components and used to fetch data from the database.

Chevron 12 steps
  • Course Introduction

    1:26

  • What Changes in Spring

    1:53

  • Revisiting Giflib

    4:55

  • Spring Review

    5 questions

  • Configuring Giflib for Hibernate

    3:03

  • Create a SessionFactory and DataSource

    17:34

  • Configuring a DataSource and SessionFactory

    1 question

  • Add JPA Annotations to Entities

    9:00

  • JPA Annotations

    1 question

  • Add JPA Annotations to an Entity

    2 objectives

  • Fetching Data with Hibernate in Spring

    6:17

  • Configure Spring for Hibernate

    3 objectives

Data-Driven Application Design

During this stage, we discuss the service-DAO software design pattern. By creating loosely-coupled components as separate layers in our applications, we can increase the maintainability, extensibility, reusability, and testability of our code.

Chevron 9 steps
  • Software Design Principles

    3:56

  • Software Design Principles

    2 questions

  • Overview of the Service-DAO Design Pattern

    1:46

  • Writing Your First DAO

    5:26

  • Add a DAO

    1 objective

  • Writing Your First Service

    3:32

  • Making Service Calls from a Controller

    2:40

  • Add a service for Contact objects

    2 objectives

  • Testing Our Service and DAO

    5:08

Getting Started with CRUD in Spring + Hibernate

With our service-DAO design pattern intact, it's time to tackle the various operations of Giflib. In this stage, we implement a post-redirect-get pattern in Spring and discuss the use of forms in Thymeleaf.

Chevron 6 steps
  • Flow of Data in a Web App

    5:33

  • Saving Entities

    2:44

  • Add Saving to DAO & Service

    3 objectives

  • Controller Method for Adding a Category

    3:29

  • HTML Form for Adding a Category

    11:44

  • Add a controller method for saving a new contact

    2 objectives

User Messages in Spring

In this stage we discuss the use of two kinds of messages to keep users informed: form validation messages and flash messages. For both of these we'll leverage Spring's RedirectAttributes in order for these messages to survive a redirect.

Chevron 9 steps
  • Intro to User Messaging

    1:05

  • A Case for Form Validation

    2:22

  • Capturing Form Validation Errors

    6:08

  • Capturing form validation errors

    2 questions

  • Re-populating Data when Validation Fails

    5:52

  • What to do when validation fails

    2 questions

  • Displaying Validation Messages

    7:20

  • Encapsulating a Flash Message

    3:43

  • Making Flash Messages Survive a Redirect

    3:48

File Uploads and Entity Updates in Spring + Hibernate

In this final stage of the course, we discuss how to allow users the ability to upload files with HTML, as well as how to process those file uploads with Spring. In addition, we take the forms for adding categories and GIFs and make them reusable for updating each of those entities.

Chevron 14 steps
  • A File Upload Form in Thymeleaf

    8:55

  • File upload markup

    1 question

  • Coding the GIF Service

    6:46

  • Coding the GIF DAO

    4:47

  • Persisting a GIF From the Controller

    7:42

  • Capturing file data in the controller

    2 questions

  • Updating Categories: Part 1

    7:58

  • Updating Categories: Part 2

    10:19

  • Updating with Hibernate

    1 question

  • Updating GIFs

    4:18

  • Deleting Categories

    14:15

  • Deleting GIFs

    2:02

  • Marking GIFs as Favorites

    4:31

  • Wrap-Up

    0:42

Syllabus

Integrating Hibernate with Spring

As a first step toward using Hibernate in a Spring application, we first discuss how to configure a Spring app to include Hibernate for data management. We'll add the necessary dependencies and configuration code so that a Hibernate SessionFactory can be autowired into Spring components and used to fetch data from the database.

Chevron 12 steps
  • Course Introduction

    1:26

  • What Changes in Spring

    1:53

  • Revisiting Giflib

    4:55

  • Spring Review

    5 questions

  • Configuring Giflib for Hibernate

    3:03

  • Create a SessionFactory and DataSource

    17:34

  • Configuring a DataSource and SessionFactory

    1 question

  • Add JPA Annotations to Entities

    9:00

  • JPA Annotations

    1 question

  • Add JPA Annotations to an Entity

    2 objectives

  • Fetching Data with Hibernate in Spring

    6:17

  • Configure Spring for Hibernate

    3 objectives

Data-Driven Application Design

During this stage, we discuss the service-DAO software design pattern. By creating loosely-coupled components as separate layers in our applications, we can increase the maintainability, extensibility, reusability, and testability of our code.

Chevron 9 steps
  • Software Design Principles

    3:56

  • Software Design Principles

    2 questions

  • Overview of the Service-DAO Design Pattern

    1:46

  • Writing Your First DAO

    5:26

  • Add a DAO

    1 objective

  • Writing Your First Service

    3:32

  • Making Service Calls from a Controller

    2:40

  • Add a service for Contact objects

    2 objectives

  • Testing Our Service and DAO

    5:08

Getting Started with CRUD in Spring + Hibernate

With our service-DAO design pattern intact, it's time to tackle the various operations of Giflib. In this stage, we implement a post-redirect-get pattern in Spring and discuss the use of forms in Thymeleaf.

Chevron 6 steps
  • Flow of Data in a Web App

    5:33

  • Saving Entities

    2:44

  • Add Saving to DAO & Service

    3 objectives

  • Controller Method for Adding a Category

    3:29

  • HTML Form for Adding a Category

    11:44

  • Add a controller method for saving a new contact

    2 objectives

User Messages in Spring

In this stage we discuss the use of two kinds of messages to keep users informed: form validation messages and flash messages. For both of these we'll leverage Spring's RedirectAttributes in order for these messages to survive a redirect.

Chevron 9 steps
  • Intro to User Messaging

    1:05

  • A Case for Form Validation

    2:22

  • Capturing Form Validation Errors

    6:08

  • Capturing form validation errors

    2 questions

  • Re-populating Data when Validation Fails

    5:52

  • What to do when validation fails

    2 questions

  • Displaying Validation Messages

    7:20

  • Encapsulating a Flash Message

    3:43

  • Making Flash Messages Survive a Redirect

    3:48

File Uploads and Entity Updates in Spring + Hibernate

In this final stage of the course, we discuss how to allow users the ability to upload files with HTML, as well as how to process those file uploads with Spring. In addition, we take the forms for adding categories and GIFs and make them reusable for updating each of those entities.

Chevron 14 steps
  • A File Upload Form in Thymeleaf

    8:55

  • File upload markup

    1 question

  • Coding the GIF Service

    6:46

  • Coding the GIF DAO

    4:47

  • Persisting a GIF From the Controller

    7:42

  • Capturing file data in the controller

    2 questions

  • Updating Categories: Part 1

    7:58

  • Updating Categories: Part 2

    10:19

  • Updating with Hibernate

    1 question

  • Updating GIFs

    4:18

  • Deleting Categories

    14:15

  • Deleting GIFs

    2:02

  • Marking GIFs as Favorites

    4:31

  • Wrap-Up

    0:42