Skip to content

A base project for tests and examples that need a realistic RDBMS to build on

License

Notifications You must be signed in to change notification settings

mstahv/sakila-spring-data-jpa-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example/demo project base with Spring Data JPA and Sakila database initialized with TestContainers

The Sakila database is a sample database schema and data that was originally developed by MySQL. It is intended to provide a standard schema that can be used for examples and tests.

This project is a starting point for simple examples/demos that need a somewhat realistic dataset. It provides Spring Data JPA based backend and uses TestContainers to initialize a database with the Sakila test database schema and data. It automatically starts Sakila DB docker images that come with pre-populated database. Delete the local container if you want to reset the database.

The DB entities where autogenerated using IntelliJ IDEA's JPA plugin with some manual modifications. There are also some handcrafted entities and repositories for views.

Branches for your favorite database

  • postgresql - PostgreSQL database
  • mysql - MySQL database

Trying to keep other differences than testcontainer configurations to the minimum.

Requirements

  • Docker
  • Java 21+
  • Maven
  • Strongly suggested: JRebel or HotswapAgent (Hibernate :-) )

Usage

  • Fork the repository for your own needs
  • Import to your favourite IDE
  • Make sure you have Docker running
  • Run the TestDemoApplication class from the src/test/java folder. This will start the Spring Boot application and initialize the database with TestContainers.
  • Utilize the "entity explorer" from the test application to browse the database state and to make limited edits during development.
  • Ready? Implement your demo app to the src/main/java folder!

Screenshot of the entity explorer available for testing and development purposes:

Screenshot 2024-12-11 at 20 41 41

Note, if you plan to use Vaadin for your example, you should recognise that the explorer is built with Vaadin and and its dependencies in the test scope may interfere with your app. Replace the Vaadin dependencies from the test scope with actual setup to default scope!

TODO, ideas for further development of the starter

  • Add missing entities/repositories
  • Add some service classes
  • Deleting existing entities (to entity explorer)
  • Branches for different database types (currently only MySQL and PostgreSQL)
  • Gradle branches (or both Maven and Gradle build files)

About

A base project for tests and examples that need a realistic RDBMS to build on

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published