Code Monkey home page Code Monkey logo

sample-spring-deprecate-tut-data's Introduction

In this tutorial you'll use Spring to store and retrieve data from multiple data stores.

Persistence and Storage

The field of Data Persistence has progressed enormously over the past 20 years. Not so long ago, if you were considering data storage and retrieval you were fairly limited to thinking in terms of a relational data store, or perhaps simple file storage.

Today there are much richer options, and Data Persistence now covers a myriad of different data models and data storage implementations.

Since you're reading this tutorial, it's likely that you are considering implementing a data storage using a component referred to as a [Repository], a pattern from Domain Driven Design, because:

  • You have a data store where you need to access and potentially modify the data that's stored.
  • You have an existing Spring Data application that you need to maintain.
  • You want to investigate different data stores in the context of Spring Data.

This tutorial covers three data stores: the MongoDB document store, a relational database using JPA and Pivotal GemFire.

What you'll build

The context for this tutorial is the Yummy Noodle Bar. As part of its planned expansion it needs to be able to store and update its Menu and store Orders.

Yummy Noodle Bar

You will extend the Yummmy Noodle Bar's application to:

  • Store Menu data in MongoDB.
  • Store Order data in a Relational Database.
  • Track the Status of an Order using GemFire.

Note: More detail on the Yummy Noodle Bar's application is available in the next section of this tutorial.

Spring Data will provide the bedrock of your persistence project, and you will discover how it makes your data access simpler, more consistent and more robust.

What you'll need

To work through this tutorial you'll need a few things:

  • About a half hour for each section. You might finish it in a week during your lunch break (or during the weekend!)
  • A copy of the code (available either by git or a downloadable zip file).
  • An IDE of your choice. Spring recommends Spring Tool Suite, which is a free download.
  • An installation of MongoDB

Downloading and running the code

If you download the code base, you'll discover each section of this tutorial in a separate folder, numbered 1, 2, 3, etc. There are also several code drops: an initial one at the root, and a separate complete code drop for each section.

The initial code set contains:

  • a project layout
  • the core domain & event classes this tutorial starts off creating (the 'Yummy Noodle Bar Application', above)
  • some basic unit tests for some of those classes

The complete code set in each section includes the initial code base plus the code developed up to that point in the tutorial.

You can choose to start with the initial code set or you can start with the complete code set for a given section. Important files from each of the steps are shown in the tutorial, such as writing tests, creating data oriented interfaces services, and looking at some key domain objects.

This tutorial is built using Gradle and includes the Gradle Wrapper, so you don't have to install anything to run the code.

For example, if you want to check out the initial code set:

$ git clone https://github.com/spring-guides/tut-data.git
$ cd tut-data/initial
$ ./gradlew clean test

From there, you can inspect build/reports/tests and see all the test results.

The Home of Persistence in your Application Architecture

Repositories are an integration between your core application and external, persistent storage engines. Repositories can be seen as living in their own Persistence integration domain on the periphery of your applications core as shown in the following diagram:

Introducing the Persistence Integration Domain

As an integration between your application core and the outside world there are a number of concerns that need to be addressed in the design and implementation of the components that make up your Repositories:

  • The primary purpose of a Repository component is to integrate your application with the data stores in a natural and optimised �(for data storage and retrieval) way.
  • Components of your persistence domain will need to evolve at a rate that is appropriate for the data they are managing.
  • Your Repository components should not contain any core logic. They should instead focus on collaborating with other components in the core domain of your application in order to support their core functionality.

That's enough on the design constraints placed on the components that implement your Repositories, the rest of this tutorial looks at how to implement those components using Spring:

sample-spring-deprecate-tut-data's People

Contributors

dawsonsystems avatar gregturn avatar matsev avatar royclarkson avatar russmiles avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.