Spring Data
eBook - ePub

Spring Data

Petri Kainulainen

Share book
  1. 160 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Spring Data

Petri Kainulainen

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Spring Framework has always had a good support for different data access technologies. However, developers had to use technology-specific APIs, which often led to a situation where a lot of boilerplate code had to be written in order to implement even the simplest operations. Spring Data changed all this. Spring Data makes it easier to implement Spring-powered applications that use cloud-based storage services, NoSQL databases, map-reduce frameworks or relational databases.

"Spring Data" is a practical guide that is full of step-by-step instructions and examples which ensure that you can start using the Java Persistence API and Redis in your applications without extra hassle.

This book provides a brief introduction to the underlying data storage technologies, gives step-by-step instructions that will help you utilize the discussed technologies in your applications, and provides a solid foundation for expanding your knowledge beyond the concepts described in this book.

You will learn an easier way to manage your entities and to create database queries with Spring Data JPA. This book also demonstrates how you can add custom functions to your repositories. You will also learn how to use the Redis key-value store as data storage and to use its other features for enhancing your applications.

"Spring Data" includes all the practical instructions and examples that provide you with all the information you need to create JPA repositories with Spring Data JPA and to utilize the performance of Redis in your applications by using Spring Data Redis.

Approach

This book is a standard tutorial which provides step-by-step instructions and a lot of code examples that are easy to follow and help you to get started from page one.

Who this book is for

This book is suited for developers who are working with Spring-powered applications, and are looking for an easier way to write data access code that uses relational databases. Also, if you are interested in learning how you can utilize Redis in your applications, this is the book for you. This book assumes that you have got some experience with the Spring Framework and the Java Persistence API. No previous experience with Redis is required.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Spring Data an online PDF/ePUB?
Yes, you can access Spring Data by Petri Kainulainen in PDF and/or ePUB format, as well as other popular books in Informatique & Sciences générales de l'informatique. We have over one million books available in our catalogue for you to explore.

Information

Year
2012
ISBN
9781849519045

Spring Data


Table of Contents

Spring Data
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started
Java Persistence API
Key concepts
Creating database queries
Native SQL queries
Java Persistence Query Language
The Criteria API
Redis
Supported data types
Persistence
Replication
Publish/subscribe messaging pattern
Summary
2. Getting Started with Spring Data JPA
Downloading dependencies with Maven
Configuring the Spring application context
Creating the properties file
Creating the application context configuration class
Creating the application context configuration skeleton
Configuring the data source bean
Configuring the entity manager factory bean
Configuring the transaction manager bean
Loading the application context configuration
Implementing CRUD functionality for an entity
Domain model
Contact
Creating new contact objects
Updating contact information
Address
Creating new addresses
Updating address information
Creating a custom repository
Creating a custom repository in the old school way
Creating a custom repository with Spring Data JPA
CRUD
Create
Read
Update
Delete
Summary
3. Building Queries with Spring Data JPA
Building queries
Query methods
Query generation from method name
Method prefixes
Property expressions
Keywords
Implementing the search function
Pros and cons
Named queries
Creating a named query
Creating the query method
Creating the service method
Pros and cons
@Query annotation
Creating the query method
Creating the service method
Pros and cons
JPA Criteria API
Adding the JPA Criteria API support to a repository
Creating the criteria query
Creating a static metamodel class
Creating specifications
Creating the service method
Pros and cons
Querydsl
Configuring Querydsl-Maven integration
Configuring Querydsl Maven dependencies
Configuring the code generation Maven plugin
Generating Querydsl query types
Adding Querydsl support to a repository
Creating the executed query
Executing the created query
Pros and cons
What technique should we use?
Sorting query results
Sorting with method name
Creating the query method
Modifying the service method
Sorting with query strings
JPQL queries
SQL queries
Sorting with the Sort class
JpaRepository
Query generation from the method name
@Query annotation
JPA Criteria API
Sorting with Querydsl
What technique should we use?
Paginating query results
Changing the service layer
Creating a class for pagination parameters
Changing the service interface
Creating PageRequest objects
Implementing pagination
JpaRepository
Query generation from the method name
Adding pagination support to the query method
Modifying the service class
Named queries
Adding pagination support to the query method
Modifying the service class
@Query annotation
Adding pagination support to a query method
Modifying the service method
JPA Criteria API
Querydsl
Summary
4. Adding Custom Functionality to JPA Repositories
Adding custom functionality to a single repository
Creating the custom interface
Implementing the created interface
Configuring the repository class
Implementing the custom methods
Creating the repository interface
Creating the service implementation
What did we just do?
Adding custom functionality to all repositories
Creating the base repository interface
Implementing the base repository interface
Creating the repository factory bean
Creating the skeleton of the repository factory bean class
Creating the repository factory inner class
Creating the builder method for the repository factory
Configuring Spring Data JPA
Creating the repository interface
Implementing the service layer
What did we just do?
Summary
5. Getting Started with Spring Data Redis
Installing Redis
Getting the required dependencies
Configuring the Spring application context
Configuring the Redis connection
Configuring the Jedis connector
Configuring the JRedis connector
Configuring the RJC connector
Configuring the SRP connector
Summary
6. Building Applications with Spring Data Redis
Designing a Redis data model
Key components
Atomic counters
RedisTemplate
Operations
Serializers
Implementing a CRUD application
Using default serializers
Configuring the application context
Configuring the Redis template bean
Configuring the Redis atomic long bean
CRUD
Create
Read
Update
Delete
Storing data in JSON
Configuring the application context
Configuring the value serializer bean
Configuring the Redis template bean
Configuring the Re...

Table of contents