Skip to content
/ courses Public

Practing spring data JPA many to many and lazy loading

Notifications You must be signed in to change notification settings

payne/courses

Repository files navigation

A quick java spring boot app to explore JPA & many to many relationship with Lazy loading

An interesting unit test is CourseLazyLoadingTest.java which explores lazy loading.

  1. It outputs the SQL generated by JPA to the log (stdout).
  2. Shows off the use of @Transactional to avoid LazyInitializationException.
  3. It shows how to use @Query to avoid N+1 queries.
  4. Shows using Hibernate.isInitialized(obj) to see if obj has been fetched from the database.

In memory h2 database

run mvn spring-boot:run to start the application then visit http://localhost:8080/h2-console to view the database

h2 login

Quick look at the sample data

Simple GUI

Visit http://localhost:8080/ to view the app

bootify generated GUI

Swagger included

Swagger

About

Practing spring data JPA many to many and lazy loading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published