
Java ORM standard JPA programming
Description
Book Introduction
The Java ORM standard JPA helps you store objects directly in a database without writing SQL, and also resolves the difference between object and relational databases.
This book covers everything about JPA, from basic theory and core principles to performance optimization methods required for practical use. It also explains how to use the Spring Framework and JPA together, and covers how to effectively develop Java web applications by leveraging innovative open source such as Spring Data JPA and QueryDSL. |
- You can preview some of the book's contents.
Preview
index
Chapter 1. Introduction to JPA
1.1 SQL and its problems
1.1.1 Repeat, repeat, and repeat
1.1.2 SQL-dependent development
1.1.3 Troubleshooting with JPA
1.2 Paradigm Mismatch
1.2.1 Inheritance
1.2.2 Relationships
1.2.3 Object Graph Traversal
1.2.4 Comparison
1.2.5 Summary
1.3 What is JPA?
1.3.1 Introduction to JPA
1.3.2 Why Use JPA?
1.4 Summary
Chapter 2. Getting Started with JPA
2.1 Installing Eclipse and Importing the Project
2.2 Installing the H2 database
2.3 Libraries and Project Structure
2.3.1 Managing Libraries with Maven
2.4 Starting Object Mapping
2.5 persistence.xml settings
2.5.1 Database Dialects
2.6 Application Development
2.6.1 Entity Manager Configuration
2.6.2 Transaction Management
2.6.3 Business Logic
2.6.4 JPQL
2.7 Summary
Chapter 3.
Persistence Management
3.1 Entity Manager Factory and Entity Manager
3.2 What is a Persistence Context?
3.3 Entity Lifecycle
3.4 Characteristics of Persistence Context
3.4.1 Entity Lookup
3.4.2 Entity Registration
3.4.3 Modifying entities
3.4.4 Deleting an Entity
3.5 flush
3.5.1 Flush Mode Options
3.6 Semi-permanent
3.6.1 Making an entity semi-persistent: detach( )
3.6.2 Initializing the Persistence Context: clear( )
3.6.3 Terminating a Persistence Context: close( )
3.6.4 Characteristics of the semi-persistent state
3.6.5 Merge: merge( )
3.7 Summary
Chapter 4.
Entity Mapping
4.1 @Entity
4.2 @Table
4.3 Using various mappings
4.4 Automatic database schema creation
4.5 DDL generation function
4.6 Default Key Mapping
4.6.1 Primary Key Direct Assignment Strategy
4.6.2 IDENTITY Strategy
4.6.3 SEQUENCE Strategy
4.6.4 TABLE Strategy
4.6.5 AUTO Strategy
4.6.6 Clean up the primary key mapping
4.7 Field and Column Mapping: Reference
4.7.1 @Column
4.7.2 @Enumerated
4.7.3 @Temporal
4.7.4 @Lob
4.7.5 @Transient
4.7.6 @Access
4.8 Summary
Practical Example 1.
Requirements Analysis and Basic Mapping
Requirements Analysis
Domain Model Analysis
Table design
Entity Design and Mapping
The Challenges of Data-Driven Design
Chapter 5.
Association Mapping Basics
5.1 Unidirectional associations
5.1.1 Pure Object Associations
5.1.2 Table Relationships
5.1.3 Object-Relational Mapping
5.1.4 @JoinColumn
5.1.5 @ManyToOne
5.2 Using Relationships
5.2.1 Save
5.2.2 Views
5.2.3 Fix
5.2.4 Removing associations
5.2.5 Deleting Related Entities
5.3 Bidirectional correlation
5.3.1 Bidirectional Association Mapping
5.3.2 One-to-Many Collection Query
5.4 Owner of the relationship
5.4.1 Rules for Bidirectional Mapping: Owner of Association
5.4.2 The owner of the relationship is where the foreign key is located.
5.5 Storing two-way associations
5.6 Notes on Bidirectional Associations
5.6.1 Bidirectional associations that consider even pure objects
5.6.2 Convenience methods for associations
5.6.3 Precautions when writing association convenience methods
5.7 Summary
Practical Example 2.
Start mapping relationships
One-to-many, many-to-one relationship mapping
Object Graph Traversal
Chapter 6.
Mapping of various relationships
6.1 Many-to-One
6.1.1 Many-to-One Unidirectional [N:1]
6.1.2 Many-to-One Bidirectional [N:1, 1:N]
6.2 One-to-many
6.2.1 One-to-Many Unidirectional [1:N]
6.2.2 One-to-many bidirectional [1:N, N:1]
6.3 One-on-one [1:1]
6.3.1 Foreign keys in the main table
6.3.2 Foreign keys in the target table
6.4 Many-to-Many [N:N]
6.4.1 Many-to-Many: One-way
6.4.2 Many-to-Many: Bidirectional
6.4.3 Many-to-Many: Limitations and Overcoming of Mapping, Using Linked Entities
6.4.4 Many-to-Many: Using a New Primary Key
6.4.5 Organizing many-to-many relationships
6.5 Summary
Practical Example 3.
Mapping of various relationships
One-to-one mapping
Many-to-many mapping
Chapter 7.
Advanced Mapping
7.1 Inheritance Relationship Mapping
7.1.1 Join Strategy
7.1.2 Single-Table Strategy
7.1.3 Table strategy for each implementation class
7.2 @MappedSuperclass
7.3 Mapping composite keys and identifying relationships
7.3.1 Identifying vs. Non-Identifying Relationships
7.3.2 Composite Keys: Non-Identifying Relationship Mapping
7.3.3 Composite Keys: Identifying Relationship Mapping
7.3.4 Implementation with non-identifying relationships
7.3.5 One-to-one identification relationship
7.3.6 Pros and Cons of Identifying and De-identifying Relationships
7.4 Join Table
7.4.1 One-to-one join table
7.4.2 One-to-Many Join Table
7.4.3 Many-to-One Join Table
7.4.4 Many-to-Many Join Table
7.5 Mapping Multiple Tables to One Entity
7.6 Summary
Practical Example 4.
Inheritance relationship mapping
Inheritance relationship mapping
@MappedSuperclass mapping
Chapter 8.
Proxy and Relationship Management
8.1 Proxy
8.1.1 Proxy Basics
8.1.2 Proxies and Identifiers
8.1.3 Proxy Verification
8.2 Immediate loading and lazy loading
8.2.1 Instant loading
8.2.2 Lazy Loading
8.2.3 Eager loading, lazy loading cleanup
8.3 Using Lazy Loading
8.3.1 Proxies and Collection Wrappers
8.3.2 JPA Basic Fetch Strategy
8.3.3 Precautions when using FetchType.EAGER in collections
8.4 Persistence Transition - CASCADE
8.4.1 Persistence Transition: Save
8.4.2 Persistence Transition: Delete
8.4.3 Types of CASCADE
8.5 Orphan Objects
8.6 Persistence Transition + Orphan Objects, Lifecycle
8.7 Summary
Practical Example 5.
Relationship Management
Setting a global fetch strategy
Persistence transition settings
Chapter 9.
value type
9.1 Default Type
9.2 Embedded Types (Composite Value Types)
9.2.1 Embedded Types and Table Mapping
9.2.2 Embedded Types and Relationships
9.2.3 @AttributeOverride: Overriding Attributes
9.2.4 Embedded Types and Null
9.3.
Value types and immutable objects
9.3.1 Value Type Sharing Reference
9.3.2 Copying Value Types
9.3.3 Immutable Objects
9.4.
Comparison of value types
9.5.
Value type collection
9.5.1 Using Value Type Collections
9.5.2 Constraints on Value Type Collections
9.6 Summary
Practical Example 6.
Value type mapping
Summary of practical examples
Chapter 10.
Object-oriented query language
10.1 Introduction to Object-Oriented Queries
10.1.1 Introduction to JPQL
10.1.2 Introduction to Criteria Queries
10.1.3 Introduction to QueryDSL
10.1.4 Introducing Native SQL
10.1.5 Using JDBC directly, using a SQL mapper framework like MyBatis
10.2 JPQL
10.2.1 Basic Grammar and Query API
10.2.2 Parameter Binding
10.2.3 Projection
10.2.4 Paging API
10.2.5 Sets and Sorting
10.2.6 JPQL Join
10.2.7 Fetch Join
10.2.8 Path Expressions
10.2.9 Subqueries
10.2.10 Conditional Expressions
10.2.11 Polymorphic Queries
10.2.12 Calling User-Defined Functions (JPA 2.1)
10.2.13 Other Summary
10.2.14 Direct Entity Use
10.2.15 Named Queries: Static Queries
10.3 Criteria
10.3.1 Criteria Basics
10.3.2 Creating a Criteria Query
10.3.3 Views
10.3.4 Set
10.3.5 Sorting
10.3.6 Join
10.3.7 Subqueries
10.3.8 IN formula
10.3.9 CASE expression
10.3.10 Parameter Definition
10.3.11 Native Function Calls
10.3.12 Dynamic Queries
10.3.13 Function Summary
10.3.14 Criteria Metamodel API
10.4 QueryDSL
10.4.1 QueryDSL Settings
10.4.2 Start
10.4.3 Search Condition Query
10.4.4 Results Check
10.4.5 Paging and Sorting
10.4.6 Group
10.4.7 Join
10.4.8 Subqueries
10.4.9 Projection and Returning Results
10.4.10 Modify, delete batch query
10.4.11 Dynamic Queries
10.4.12 Method Delegation
10.4.13 QueryDSL Summary
10.5 Native SQL
10.5.1 Using Native SQL
10.5.2 Named Native SQL
10.5.3 Native SQL defined in XML
10.5.4 Native SQL Summary
10.5.5 Stored Procedures (JPA 2.1)
10.6 Advanced Object-Oriented Queries
10.6.1 Bulk Operations
10.6.2 Persistence Contexts and JPQL
10.6.3 JPQL and Flush Mode
10.7 Summary
Chapter 11.
Web application development
11.1 Project Settings
11.1.1 Project Structure
11.1.2 Managing Libraries with Maven
11.1.3 Spring Framework Configuration
11.2 Domain Model and Table Design
11.2.1 Requirements Analysis
11.2.2 Domain Model Design
11.2.3 Table Design
11.2.4 Relationship Management
11.2.5 Entity Classes
11.3 Application Implementation
11.3.1 Development Methods
11.3.2 Member Functions
11.3.3 Product Features
11.3.4 Order Function
11.3.5 Web Layer Implementation
11.4 Summary
Chapter 12.
Spring Data JPA
12.1 Introduction to Spring Data JPA
12.1.1 Spring Data Project
12.2 Spring Data JPA Configuration
12.3 Common Interface Features
12.4 Query Method Functions
12.4.1 Creating queries by method name
12.4.2 JPA NamedQuery
12.4.3 @Query, defining queries in repository methods
12.4.4 Parameter Binding
12.4.5 Bulk Modification Queries
12.4.6 Return Type
12.4.7 Paging and Sorting
12.4.8 Hint
12.4.9 Lock
12.5 Specifications
12.6 Implementing a Custom Repository
12.7 Web Extensions
12.7.1 Settings
12.7.2 Domain Class Converter Function
12.7.3 Paging and Sorting Functions
12.8 Implementations Used by Spring Data JPA
12.9 Applies to JPA shops
12.9.1 Preferences
12.9.2 Refactoring the Repository
12.9.3 Specification Application
12.10 Spring Data JPA and QueryDSL Integration
12.10.1 Using QueryDslPredicateExecutor
12.10.3 Using QueryDslRepositorySupport
12.11 Summary
Chapter 13.
Web Applications and Persistence Management
13.1 Transaction-Scoped Persistence Context
13.1.1 Basic Strategies of the Spring Container
13.2 Semi-persistent State and Lazy Loading
13.2.1 Modified global fetch strategy
13.2.2 JPQL Fetch Join
13.2.3 Force Reset
13.2.4 Adding a FACADE layer
13.2.5 Problems with Semi-Persistent State and Lazy Loading
13.3 OSIV
13.3.1 Past OSIV: Transactions per Request
13.3.2 Spring OSIV: Business Layer Transactions
13.3.3 OSIV Summary
13.4 Too strict hierarchy
13.5 Summary
Chapter 14.
Collections and Add-ons
14.1 Collection
14.1.1 JPA and Collections
14.1.2 Collection, List
14.1.3 Set
14.1.4 List + @OrderColumn
14.1.5 @OrderBy
14.2 @Converter
14.2.1 Global Settings
14.3 Listener
14.3.1 Event Types
14.3.2 Event Application Location
14.4 Entity Graph
14.4.1 Named Entity Graph
14.4.2 Using Entity Graphs in em.find( )
14.4.3 subgraph
14.4.4 Using Entity Graphs in JPQL
14.4.5 Dynamic Entity Graph
14.4.6 Entity Graph Cleanup
14.5 Summary
Chapter 15.
Advanced topics and performance optimization
15.1 Exception Handling
15.1.1 JPA Standard Exception Summary
15.1.2 JPA Exception Conversion in the Spring Framework
15.1.3 Applying JPA Exception Converters to the Spring Framework
15.1.4 Notes on Transaction Rollback
15.2 Comparing entities
15.2.1 Comparing entities when the persistence context is the same
15.2.2 Comparing entities when the persistence context is different
15.3 Proxy Advanced Topics
15.3.1 Persistence Contexts and Proxies
15.3.2 Comparison of proxy types
15.3.3 Proxy Equivalence Comparison
15.3.4 Inheritance and Proxies
15.4 Performance Optimization
15.4.1 N+1 Problem
15.4.2 Optimizing the Performance of Read-Only Queries
15.4.3 Batch Processing
15.4.4 Using SQL Query Hints
15.4.5 Write Latency and Performance Optimizations Supporting Transactions
15.5 Summary
Chapter 16.
Transactions, locks, and secondary cache
16.1 Transactions and Locks
16.1.1 Transactions and Isolation Levels
16.1.2 Optimistic and Pessimistic Locking Basics
16.1.3 @Version
16.1.4 Using JPA Locks
16.1.5 JPA Optimistic Locking
16.1.6 JPA Pessimistic Locking
16.1.7 Pessimistic Locking and Timeouts
16.2 Secondary Cache
16.2.1 Primary and Secondary Cache
16.2.2 JPA Second-Level Cache Feature
16.2.3 Applying Hibernate and EHCACHE
16.3 Summary
1.1 SQL and its problems
1.1.1 Repeat, repeat, and repeat
1.1.2 SQL-dependent development
1.1.3 Troubleshooting with JPA
1.2 Paradigm Mismatch
1.2.1 Inheritance
1.2.2 Relationships
1.2.3 Object Graph Traversal
1.2.4 Comparison
1.2.5 Summary
1.3 What is JPA?
1.3.1 Introduction to JPA
1.3.2 Why Use JPA?
1.4 Summary
Chapter 2. Getting Started with JPA
2.1 Installing Eclipse and Importing the Project
2.2 Installing the H2 database
2.3 Libraries and Project Structure
2.3.1 Managing Libraries with Maven
2.4 Starting Object Mapping
2.5 persistence.xml settings
2.5.1 Database Dialects
2.6 Application Development
2.6.1 Entity Manager Configuration
2.6.2 Transaction Management
2.6.3 Business Logic
2.6.4 JPQL
2.7 Summary
Chapter 3.
Persistence Management
3.1 Entity Manager Factory and Entity Manager
3.2 What is a Persistence Context?
3.3 Entity Lifecycle
3.4 Characteristics of Persistence Context
3.4.1 Entity Lookup
3.4.2 Entity Registration
3.4.3 Modifying entities
3.4.4 Deleting an Entity
3.5 flush
3.5.1 Flush Mode Options
3.6 Semi-permanent
3.6.1 Making an entity semi-persistent: detach( )
3.6.2 Initializing the Persistence Context: clear( )
3.6.3 Terminating a Persistence Context: close( )
3.6.4 Characteristics of the semi-persistent state
3.6.5 Merge: merge( )
3.7 Summary
Chapter 4.
Entity Mapping
4.1 @Entity
4.2 @Table
4.3 Using various mappings
4.4 Automatic database schema creation
4.5 DDL generation function
4.6 Default Key Mapping
4.6.1 Primary Key Direct Assignment Strategy
4.6.2 IDENTITY Strategy
4.6.3 SEQUENCE Strategy
4.6.4 TABLE Strategy
4.6.5 AUTO Strategy
4.6.6 Clean up the primary key mapping
4.7 Field and Column Mapping: Reference
4.7.1 @Column
4.7.2 @Enumerated
4.7.3 @Temporal
4.7.4 @Lob
4.7.5 @Transient
4.7.6 @Access
4.8 Summary
Practical Example 1.
Requirements Analysis and Basic Mapping
Requirements Analysis
Domain Model Analysis
Table design
Entity Design and Mapping
The Challenges of Data-Driven Design
Chapter 5.
Association Mapping Basics
5.1 Unidirectional associations
5.1.1 Pure Object Associations
5.1.2 Table Relationships
5.1.3 Object-Relational Mapping
5.1.4 @JoinColumn
5.1.5 @ManyToOne
5.2 Using Relationships
5.2.1 Save
5.2.2 Views
5.2.3 Fix
5.2.4 Removing associations
5.2.5 Deleting Related Entities
5.3 Bidirectional correlation
5.3.1 Bidirectional Association Mapping
5.3.2 One-to-Many Collection Query
5.4 Owner of the relationship
5.4.1 Rules for Bidirectional Mapping: Owner of Association
5.4.2 The owner of the relationship is where the foreign key is located.
5.5 Storing two-way associations
5.6 Notes on Bidirectional Associations
5.6.1 Bidirectional associations that consider even pure objects
5.6.2 Convenience methods for associations
5.6.3 Precautions when writing association convenience methods
5.7 Summary
Practical Example 2.
Start mapping relationships
One-to-many, many-to-one relationship mapping
Object Graph Traversal
Chapter 6.
Mapping of various relationships
6.1 Many-to-One
6.1.1 Many-to-One Unidirectional [N:1]
6.1.2 Many-to-One Bidirectional [N:1, 1:N]
6.2 One-to-many
6.2.1 One-to-Many Unidirectional [1:N]
6.2.2 One-to-many bidirectional [1:N, N:1]
6.3 One-on-one [1:1]
6.3.1 Foreign keys in the main table
6.3.2 Foreign keys in the target table
6.4 Many-to-Many [N:N]
6.4.1 Many-to-Many: One-way
6.4.2 Many-to-Many: Bidirectional
6.4.3 Many-to-Many: Limitations and Overcoming of Mapping, Using Linked Entities
6.4.4 Many-to-Many: Using a New Primary Key
6.4.5 Organizing many-to-many relationships
6.5 Summary
Practical Example 3.
Mapping of various relationships
One-to-one mapping
Many-to-many mapping
Chapter 7.
Advanced Mapping
7.1 Inheritance Relationship Mapping
7.1.1 Join Strategy
7.1.2 Single-Table Strategy
7.1.3 Table strategy for each implementation class
7.2 @MappedSuperclass
7.3 Mapping composite keys and identifying relationships
7.3.1 Identifying vs. Non-Identifying Relationships
7.3.2 Composite Keys: Non-Identifying Relationship Mapping
7.3.3 Composite Keys: Identifying Relationship Mapping
7.3.4 Implementation with non-identifying relationships
7.3.5 One-to-one identification relationship
7.3.6 Pros and Cons of Identifying and De-identifying Relationships
7.4 Join Table
7.4.1 One-to-one join table
7.4.2 One-to-Many Join Table
7.4.3 Many-to-One Join Table
7.4.4 Many-to-Many Join Table
7.5 Mapping Multiple Tables to One Entity
7.6 Summary
Practical Example 4.
Inheritance relationship mapping
Inheritance relationship mapping
@MappedSuperclass mapping
Chapter 8.
Proxy and Relationship Management
8.1 Proxy
8.1.1 Proxy Basics
8.1.2 Proxies and Identifiers
8.1.3 Proxy Verification
8.2 Immediate loading and lazy loading
8.2.1 Instant loading
8.2.2 Lazy Loading
8.2.3 Eager loading, lazy loading cleanup
8.3 Using Lazy Loading
8.3.1 Proxies and Collection Wrappers
8.3.2 JPA Basic Fetch Strategy
8.3.3 Precautions when using FetchType.EAGER in collections
8.4 Persistence Transition - CASCADE
8.4.1 Persistence Transition: Save
8.4.2 Persistence Transition: Delete
8.4.3 Types of CASCADE
8.5 Orphan Objects
8.6 Persistence Transition + Orphan Objects, Lifecycle
8.7 Summary
Practical Example 5.
Relationship Management
Setting a global fetch strategy
Persistence transition settings
Chapter 9.
value type
9.1 Default Type
9.2 Embedded Types (Composite Value Types)
9.2.1 Embedded Types and Table Mapping
9.2.2 Embedded Types and Relationships
9.2.3 @AttributeOverride: Overriding Attributes
9.2.4 Embedded Types and Null
9.3.
Value types and immutable objects
9.3.1 Value Type Sharing Reference
9.3.2 Copying Value Types
9.3.3 Immutable Objects
9.4.
Comparison of value types
9.5.
Value type collection
9.5.1 Using Value Type Collections
9.5.2 Constraints on Value Type Collections
9.6 Summary
Practical Example 6.
Value type mapping
Summary of practical examples
Chapter 10.
Object-oriented query language
10.1 Introduction to Object-Oriented Queries
10.1.1 Introduction to JPQL
10.1.2 Introduction to Criteria Queries
10.1.3 Introduction to QueryDSL
10.1.4 Introducing Native SQL
10.1.5 Using JDBC directly, using a SQL mapper framework like MyBatis
10.2 JPQL
10.2.1 Basic Grammar and Query API
10.2.2 Parameter Binding
10.2.3 Projection
10.2.4 Paging API
10.2.5 Sets and Sorting
10.2.6 JPQL Join
10.2.7 Fetch Join
10.2.8 Path Expressions
10.2.9 Subqueries
10.2.10 Conditional Expressions
10.2.11 Polymorphic Queries
10.2.12 Calling User-Defined Functions (JPA 2.1)
10.2.13 Other Summary
10.2.14 Direct Entity Use
10.2.15 Named Queries: Static Queries
10.3 Criteria
10.3.1 Criteria Basics
10.3.2 Creating a Criteria Query
10.3.3 Views
10.3.4 Set
10.3.5 Sorting
10.3.6 Join
10.3.7 Subqueries
10.3.8 IN formula
10.3.9 CASE expression
10.3.10 Parameter Definition
10.3.11 Native Function Calls
10.3.12 Dynamic Queries
10.3.13 Function Summary
10.3.14 Criteria Metamodel API
10.4 QueryDSL
10.4.1 QueryDSL Settings
10.4.2 Start
10.4.3 Search Condition Query
10.4.4 Results Check
10.4.5 Paging and Sorting
10.4.6 Group
10.4.7 Join
10.4.8 Subqueries
10.4.9 Projection and Returning Results
10.4.10 Modify, delete batch query
10.4.11 Dynamic Queries
10.4.12 Method Delegation
10.4.13 QueryDSL Summary
10.5 Native SQL
10.5.1 Using Native SQL
10.5.2 Named Native SQL
10.5.3 Native SQL defined in XML
10.5.4 Native SQL Summary
10.5.5 Stored Procedures (JPA 2.1)
10.6 Advanced Object-Oriented Queries
10.6.1 Bulk Operations
10.6.2 Persistence Contexts and JPQL
10.6.3 JPQL and Flush Mode
10.7 Summary
Chapter 11.
Web application development
11.1 Project Settings
11.1.1 Project Structure
11.1.2 Managing Libraries with Maven
11.1.3 Spring Framework Configuration
11.2 Domain Model and Table Design
11.2.1 Requirements Analysis
11.2.2 Domain Model Design
11.2.3 Table Design
11.2.4 Relationship Management
11.2.5 Entity Classes
11.3 Application Implementation
11.3.1 Development Methods
11.3.2 Member Functions
11.3.3 Product Features
11.3.4 Order Function
11.3.5 Web Layer Implementation
11.4 Summary
Chapter 12.
Spring Data JPA
12.1 Introduction to Spring Data JPA
12.1.1 Spring Data Project
12.2 Spring Data JPA Configuration
12.3 Common Interface Features
12.4 Query Method Functions
12.4.1 Creating queries by method name
12.4.2 JPA NamedQuery
12.4.3 @Query, defining queries in repository methods
12.4.4 Parameter Binding
12.4.5 Bulk Modification Queries
12.4.6 Return Type
12.4.7 Paging and Sorting
12.4.8 Hint
12.4.9 Lock
12.5 Specifications
12.6 Implementing a Custom Repository
12.7 Web Extensions
12.7.1 Settings
12.7.2 Domain Class Converter Function
12.7.3 Paging and Sorting Functions
12.8 Implementations Used by Spring Data JPA
12.9 Applies to JPA shops
12.9.1 Preferences
12.9.2 Refactoring the Repository
12.9.3 Specification Application
12.10 Spring Data JPA and QueryDSL Integration
12.10.1 Using QueryDslPredicateExecutor
12.10.3 Using QueryDslRepositorySupport
12.11 Summary
Chapter 13.
Web Applications and Persistence Management
13.1 Transaction-Scoped Persistence Context
13.1.1 Basic Strategies of the Spring Container
13.2 Semi-persistent State and Lazy Loading
13.2.1 Modified global fetch strategy
13.2.2 JPQL Fetch Join
13.2.3 Force Reset
13.2.4 Adding a FACADE layer
13.2.5 Problems with Semi-Persistent State and Lazy Loading
13.3 OSIV
13.3.1 Past OSIV: Transactions per Request
13.3.2 Spring OSIV: Business Layer Transactions
13.3.3 OSIV Summary
13.4 Too strict hierarchy
13.5 Summary
Chapter 14.
Collections and Add-ons
14.1 Collection
14.1.1 JPA and Collections
14.1.2 Collection, List
14.1.3 Set
14.1.4 List + @OrderColumn
14.1.5 @OrderBy
14.2 @Converter
14.2.1 Global Settings
14.3 Listener
14.3.1 Event Types
14.3.2 Event Application Location
14.4 Entity Graph
14.4.1 Named Entity Graph
14.4.2 Using Entity Graphs in em.find( )
14.4.3 subgraph
14.4.4 Using Entity Graphs in JPQL
14.4.5 Dynamic Entity Graph
14.4.6 Entity Graph Cleanup
14.5 Summary
Chapter 15.
Advanced topics and performance optimization
15.1 Exception Handling
15.1.1 JPA Standard Exception Summary
15.1.2 JPA Exception Conversion in the Spring Framework
15.1.3 Applying JPA Exception Converters to the Spring Framework
15.1.4 Notes on Transaction Rollback
15.2 Comparing entities
15.2.1 Comparing entities when the persistence context is the same
15.2.2 Comparing entities when the persistence context is different
15.3 Proxy Advanced Topics
15.3.1 Persistence Contexts and Proxies
15.3.2 Comparison of proxy types
15.3.3 Proxy Equivalence Comparison
15.3.4 Inheritance and Proxies
15.4 Performance Optimization
15.4.1 N+1 Problem
15.4.2 Optimizing the Performance of Read-Only Queries
15.4.3 Batch Processing
15.4.4 Using SQL Query Hints
15.4.5 Write Latency and Performance Optimizations Supporting Transactions
15.5 Summary
Chapter 16.
Transactions, locks, and secondary cache
16.1 Transactions and Locks
16.1.1 Transactions and Isolation Levels
16.1.2 Optimistic and Pessimistic Locking Basics
16.1.3 @Version
16.1.4 Using JPA Locks
16.1.5 JPA Optimistic Locking
16.1.6 JPA Pessimistic Locking
16.1.7 Pessimistic Locking and Timeouts
16.2 Secondary Cache
16.2.1 Primary and Secondary Cache
16.2.2 JPA Second-Level Cache Feature
16.2.3 Applying Hibernate and EHCACHE
16.3 Summary
Publisher's Review
★ What this book covers ★
■ JPA Basic Theory and Core Principles
■ Explains the process of designing a domain model using JPA with examples.
■ Description of various object-oriented query languages
■ How to develop web applications using JPA and Spring Framework together
■ Introduction and Use of Spring Data JPA and QueryDSL
■ Various ways to optimize performance when using JPA in practice
★ Target audience for this book ★
This book is intended for all Java developers who want to develop enterprise applications using JPA.
To understand the contents of this book, you should have some knowledge of the Java language, database programming using JDBC, object-oriented programming, and relational databases.
Additionally, Part 3 requires basic knowledge of web development and the Spring Framework, and the ability to handle JUnit.
And running the example code also requires some knowledge of Maven.
★ Structure of this book ★
JPA can be broadly divided into a design part that deals with how to map objects and tables, and a part that actually uses the designed model.
In the first part of the book, you will learn basic theories and design methods, and in the second part, you will develop actual web applications using JPA based on the theories you have learned.
This book is divided into four major parts.
Chapters 1 through 9 are theoretical.
Learn how to map objects and tables and the core features of JPA.
Chapters 4 through 9 provide practical examples at the end of each chapter that gradually design a domain model, allowing you to apply what you have learned in practice.
Chapter 10 covers object-oriented query languages. We'll explore everything from JPQL (Java Persistence Query Language), the object-oriented query language provided by JPA, to native SQL, which allows you to write SQL directly.
Chapters 11 and 12 are practical guides for using JPA in practice.
Learn how to develop web applications using the Spring Framework and JPA, and also try out innovative open source tools like Spring Data JPA and QueryDSL.
Chapters 13 through 16 cover various advanced topics in JPA, including transactions, locks, caches, and performance optimizations.
★ Online Lecture ★
So far, JPA has been introduced to various practical projects.
I've designed and developed everything from simple web services to ordering, payment, and settlement systems handling billions of transactions, all using JPA. While initially implementing JPA in my practice was a bit of a challenge, it has significantly improved development productivity and maintenance, allowing me to devote more time to code quality and testing.
Above all, colleagues who had used JPA did not want to go back.
However, there were many difficulties due to the lack of domestic data on JPA.
So I wrote this book myself in 2015.
We offer paid online lectures that can be viewed along with the book.
After publishing the book, I gave lectures at many companies that are using or planning to introduce JPA, from internet business companies like Naver and Kakao to e-commerce companies like Woowa Brothers and 11st.
After hearing from developers that they were able to easily understand parts that were difficult to understand in books through lectures, we opened an online course.
For reference, the lecture uses the latest versions of Spring Boot and JPA, and is easy to follow with code.
And we focused more on imparting practical know-how.
I hope you too can confidently use JPA in your work.
You can take the online course at the following link.
■ Lecture Link: https://www.inflearn.com/roadmaps/149
■ List of online lectures
Java ORM Standard JPA Programming - Basics: https://www.inflearn.com/course/ORM-JPA-Basic
Real-World! Spring Boot and JPA Utilization 1 - Web Application Development: https://www.inflearn.com/course/springboot-jpa-utilization-1
Real-World! Spring Boot and JPA Utilization 2 - API Development and Performance Optimization: https://www.inflearn.com/course/springboot-jpa-api-development-performance-optimization#
Practice! Spring Data JPA: https://www.inflearn.com/course/spring-data-jpa-practice
-Practice! Querydsl: https://www.inflearn.com/course/Querydsl-Practice
★ Author's Note ★
I still remember the surprise I felt when I first encountered JPA.
Countless CRUD codes and SQL statements I've written to manage objects in relational databases flashed through my mind.
It was like encountering the latest tractor while planting rice seedlings in the countryside.
Storing objects in a relational database can be time-consuming and code-intensive.
From simple tasks like converting an object to SQL to complex tasks like storing the object's inheritance structure in a table, developers have to write countless mapping codes and SQL between objects and the database.
To solve this problem, the Java community provides a standard technology called JPA.
The Java ORM standard JPA helps you store objects directly in a database without writing SQL, and also resolves the difference between object and relational databases.
While introducing JPA to our work was initially challenging, development productivity and maintenance have significantly improved, allowing us to devote more time to code quality and testing.
And my colleagues who had tried JPA didn't want to go back.
However, there was a lack of domestic data on JPA, and most of it was original, which made it difficult.
So, I had a vague idea that I would like to write a book about JPA when the time comes, and then Ilmin Lee, the author of Toby's Spring 3 and Toby's Spring 3.1, recommended that I write a book about JPA.
I decided to write a book, thinking that six months would be enough, but time flew by and two years had already passed.
This book focuses on covering everything about JPA, from basic theory and core principles to performance optimization methods required for practical use.
Additionally, we explain how to use the Spring Framework and JPA together, and how to effectively develop Java web applications by leveraging innovative open source such as Spring Data JPA and QueryDSL.
Looking back, I think I've come this far thanks to those who waited for and supported my insignificant book.
I would like to express my sincere gratitude to all of you, as you have been a great help.
I hope this book will be of some help to those who are starting out with JPA.
■ JPA Basic Theory and Core Principles
■ Explains the process of designing a domain model using JPA with examples.
■ Description of various object-oriented query languages
■ How to develop web applications using JPA and Spring Framework together
■ Introduction and Use of Spring Data JPA and QueryDSL
■ Various ways to optimize performance when using JPA in practice
★ Target audience for this book ★
This book is intended for all Java developers who want to develop enterprise applications using JPA.
To understand the contents of this book, you should have some knowledge of the Java language, database programming using JDBC, object-oriented programming, and relational databases.
Additionally, Part 3 requires basic knowledge of web development and the Spring Framework, and the ability to handle JUnit.
And running the example code also requires some knowledge of Maven.
★ Structure of this book ★
JPA can be broadly divided into a design part that deals with how to map objects and tables, and a part that actually uses the designed model.
In the first part of the book, you will learn basic theories and design methods, and in the second part, you will develop actual web applications using JPA based on the theories you have learned.
This book is divided into four major parts.
Chapters 1 through 9 are theoretical.
Learn how to map objects and tables and the core features of JPA.
Chapters 4 through 9 provide practical examples at the end of each chapter that gradually design a domain model, allowing you to apply what you have learned in practice.
Chapter 10 covers object-oriented query languages. We'll explore everything from JPQL (Java Persistence Query Language), the object-oriented query language provided by JPA, to native SQL, which allows you to write SQL directly.
Chapters 11 and 12 are practical guides for using JPA in practice.
Learn how to develop web applications using the Spring Framework and JPA, and also try out innovative open source tools like Spring Data JPA and QueryDSL.
Chapters 13 through 16 cover various advanced topics in JPA, including transactions, locks, caches, and performance optimizations.
★ Online Lecture ★
So far, JPA has been introduced to various practical projects.
I've designed and developed everything from simple web services to ordering, payment, and settlement systems handling billions of transactions, all using JPA. While initially implementing JPA in my practice was a bit of a challenge, it has significantly improved development productivity and maintenance, allowing me to devote more time to code quality and testing.
Above all, colleagues who had used JPA did not want to go back.
However, there were many difficulties due to the lack of domestic data on JPA.
So I wrote this book myself in 2015.
We offer paid online lectures that can be viewed along with the book.
After publishing the book, I gave lectures at many companies that are using or planning to introduce JPA, from internet business companies like Naver and Kakao to e-commerce companies like Woowa Brothers and 11st.
After hearing from developers that they were able to easily understand parts that were difficult to understand in books through lectures, we opened an online course.
For reference, the lecture uses the latest versions of Spring Boot and JPA, and is easy to follow with code.
And we focused more on imparting practical know-how.
I hope you too can confidently use JPA in your work.
You can take the online course at the following link.
■ Lecture Link: https://www.inflearn.com/roadmaps/149
■ List of online lectures
Java ORM Standard JPA Programming - Basics: https://www.inflearn.com/course/ORM-JPA-Basic
Real-World! Spring Boot and JPA Utilization 1 - Web Application Development: https://www.inflearn.com/course/springboot-jpa-utilization-1
Real-World! Spring Boot and JPA Utilization 2 - API Development and Performance Optimization: https://www.inflearn.com/course/springboot-jpa-api-development-performance-optimization#
Practice! Spring Data JPA: https://www.inflearn.com/course/spring-data-jpa-practice
-Practice! Querydsl: https://www.inflearn.com/course/Querydsl-Practice
★ Author's Note ★
I still remember the surprise I felt when I first encountered JPA.
Countless CRUD codes and SQL statements I've written to manage objects in relational databases flashed through my mind.
It was like encountering the latest tractor while planting rice seedlings in the countryside.
Storing objects in a relational database can be time-consuming and code-intensive.
From simple tasks like converting an object to SQL to complex tasks like storing the object's inheritance structure in a table, developers have to write countless mapping codes and SQL between objects and the database.
To solve this problem, the Java community provides a standard technology called JPA.
The Java ORM standard JPA helps you store objects directly in a database without writing SQL, and also resolves the difference between object and relational databases.
While introducing JPA to our work was initially challenging, development productivity and maintenance have significantly improved, allowing us to devote more time to code quality and testing.
And my colleagues who had tried JPA didn't want to go back.
However, there was a lack of domestic data on JPA, and most of it was original, which made it difficult.
So, I had a vague idea that I would like to write a book about JPA when the time comes, and then Ilmin Lee, the author of Toby's Spring 3 and Toby's Spring 3.1, recommended that I write a book about JPA.
I decided to write a book, thinking that six months would be enough, but time flew by and two years had already passed.
This book focuses on covering everything about JPA, from basic theory and core principles to performance optimization methods required for practical use.
Additionally, we explain how to use the Spring Framework and JPA together, and how to effectively develop Java web applications by leveraging innovative open source such as Spring Data JPA and QueryDSL.
Looking back, I think I've come this far thanks to those who waited for and supported my insignificant book.
I would like to express my sincere gratitude to all of you, as you have been a great help.
I hope this book will be of some help to those who are starting out with JPA.
GOODS SPECIFICS
- Date of publication: July 28, 2015
- Page count, weight, size: 736 pages | 1,261g | 188*250*36mm
- ISBN13: 9788960777330
- ISBN10: 8960777331
You may also like
카테고리
korean
korean