Reader small image

You're reading from  jOOQ Masterclass

Product typeBook
Published inAug 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800566897
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Anghel Leonard
Anghel Leonard
author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard

Right arrow

Preface

The last decade has constantly changed how we think and write applications including the persistence layer, which must face new challenges such as working in microservice architectures and cloud environments. Flexibility, versatility, dialect agnostic, rock-solid SQL support, small learning curve, and high performance are just a few of the attributes that makes jOOQ the most appealing persistence technology for modern applications.

Being part of the modern technology stack, jOOQ is the new persistence trend that respects all standards of a mature, robust, and well-documented technology. This book covers jOOQ in detail, so it prepares you to become a jOOQ power-user and an upgraded version of yourself ready to handle the future of the persistence layer. Don't think of jOOQ as just another piece of technology; think of it as part of your mindset, your straightforward road to exploiting SQL instead of abstracting it, and your approach to doing things right in your organization.

Who this book is for

This book is for Java developers who write applications that interact with databases via SQL. No prior experience with jOOQ is assumed.

What this book covers

Chapter 1, Starting jOOQ and Spring Boot, shows how to create a kickoff application that involves jOOQ and Spring Boot in Java/Kotlin under Maven/Gradle.

Chapter 2, Customizing the jOOQ Level of Involvement, covers the configurations (declarative and programmatic) needed for employing jOOQ as a type-safe query builder and executor. Moreover, we set up jOOQ to generate POJOs and DAOs on our behalf. We use Java/Kotlin under Maven/Gradle.

Chapter 3, jOOQ Core Concepts, discusses jOOQ core concepts such as fluent API, SQL syntax correctness, emulating missing syntax/logic, jOOQ result set, jOOQ records, type safety, CRUD binding, and inlining parameters.

Chapter 4, Building a DAO Layer (Evolving the Generated DAO Layer), shows how implementing a DAO layer can be done in several ways/templates. We tackle an approach for evolving the DAO layer generated by jOOQ.

Chapter 5, Tackling Different Kinds of SELECT, INSERT, UPDATE, DELETE, and MERGE Statements, covers different kinds of SELECT, INSERT, UPDATE, DELETE, and MERGE queries. For example, we cover nested SELECT, INSERT...DEFAULT VALUES, INSERT...SET queries, and so on.

Chapter 6, Tackling Different Kinds of JOIN Statements, tackles different kinds of JOIN. jOOQ excels on standard and non-standard JOIN. We cover INNER, LEFT, RIGHT, …, CROSS, NATURAL, and LATERAL JOIN.

Chapter 7, Types, Converters, and Bindings, covers the custom data types, conversion, and binding.

Chapter 8, Fetching and Mapping, being one of the most comprehensive chapters, covers a wide range of jOOQ fetching and mapping techniques, including JSON/SQL, XML/SQL, and MULTISET features.

Chapter 9, CRUD, Transactions, and Locking, covers jOOQ CRUD support next to Spring/jOOQ transactions and optimistic/pessimistic locking.

Chapter 10, Exporting, Batching, Bulking, and Loading, covers batching, bulking, and loading files into the database via jOOQ. We will do single-thread and multi-thread batching.

Chapter 11, jOOQ Keys, tackles the different kinds of identifiers (auto-generated, natural IDs, and composite IDs) from the jOOQ perspective.

Chapter 12, Pagination and Dynamic Queries, covers pagination and building dynamic queries. Mainly, all jOOQ queries are dynamic, but in this chapter, we will highlight this, and we will write several filters by gluing and reusing different jOOQ artifacts.

Chapter 13, Exploiting SQL Functions, covers window functions (probably the most powerful SQL feature) in the jOOQ context.

Chapter 14, Derived Tables, CTEs, and Views, covers derived tables and recursive Common Table Expressions (CTEs) in the jOOQ context.

Chapter 15, Calling and Creating Stored Functions and Procedures, covers stored procedures and functions in the jOOQ context. This is one of the most powerful and popular jOOQ features.

Chapter 16, Tackling Aliases and SQL Templating, covers aliases and SQL templating. As you'll see, this chapter contains a must-have set of knowledge that will help you to avoid common related pitfalls.

Chapter 17, Multitenancy in jOOQ, covers different aspects of multi-tenancy/partitioning.

Chapter 18, jOOQ SPI (Providers and Listeners), covers jOOQ providers and listeners. Using these kinds of artifacts, we can interfere with the default behavior of jOOQ.

Chapter 19, Logging and Testing, covers jOOQ logging and testing.

To get the most out of this book

To get the most out of this book, you'll need to know the Java language and be familiar with one of the following database technologies:

Refer to this link for additional installation instructions and information you need to set things up: https://github.com/PacktPublishing/jOOQ-Masterclass/tree/master/db.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/jOOQ-Masterclass. If there's an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/a1q9L.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "For instance, the next snippet of code relies on the fetchInto() flavor."

A block of code is set as follows:

// 'query' is the ResultQuery object
List<Office> result = query.fetchInto(Office.class);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public List<Office> findOfficesInTerritory(
                                    String territory) {
  List<Office> result = ctx.selectFrom(table("office"))
    .where(field("territory").eq(territory))
    .fetchInto(Office.class); 
  return result;
}

Any command-line input or output is written as follows:

<result>
 <record>
  <value field="product_line">Vintage Cars</value>
  <value field="product_id">80</value>
  <value field="product_name">1936 Mercedes Benz ...</value>
 </record>
 ...
</result>

Tips or Important Notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you've read jOOQ Masterclass, we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
jOOQ Masterclass
Published in: Aug 2022Publisher: PacktISBN-13: 9781800566897
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard