Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
jOOQ Masterclass
jOOQ Masterclass

jOOQ Masterclass: A practical guide for Java developers to write SQL queries for complex database interactions

By Anghel Leonard
$51.99
Book Aug 2022 764 pages 1st Edition
eBook
$41.99 $28.99
Print
$51.99
Subscription
$15.99 Monthly
eBook
$41.99 $28.99
Print
$51.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Aug 19, 2022
Length 764 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781800566897
Category :
Languages :
Table of content icon View table of contents Preview book icon Preview Book

jOOQ Masterclass

Chapter 1: Starting jOOQ and Spring Boot

This chapter is a practical guide to start working with jOOQ (open source and free trial commercial) in Spring Boot applications. For convenience, let's assume that we have a Spring Boot stub application and plan to implement the persistence layer via jOOQ.

The goal of this chapter is to highlight the fact that setting the environment for generating and executing SQL queries via jOOQ in a Spring Boot application is a job that can be accomplished almost instantly in any of the Java/Kotlin and Maven/Gradle combinations. Besides that, this is a good opportunity to have your first taste of the jOOQ DSL-fluent API and to get your first impressions.

The topics of this chapter include the following:

  • Starting jOOQ and Spring Boot instantly
  • Using the jOOQ query DSL API to generate a valid SQL statement
  • Executing the generated SQL and mapping the result set to a POJO

Let's get started!

Technical requirements

The code for this chapter can be found on GitHub at https://github.com/PacktPublishing/jOOQ-Masterclass/tree/master/Chapter01.

Starting jOOQ and Spring Boot instantly

Spring Boot provides support for jOOQ, and this aspect is introduced in the Spring Boot official documentation under the Using jOOQ section. Having built-in support for jOOQ makes our mission easier, since, among other things, Spring Boot is capable of dealing with aspects that involve useful default configurations and settings.

Consider having a Spring Boot stub application that will run against MySQL and Oracle, and let's try to add jOOQ to this context. The goal is to use jOOQ as a SQL builder for constructing valid SQL statements and as a SQL executor that maps the result set to a POJO.

Adding the jOOQ open source edition

Adding the jOOQ open source edition into a Spring Boot application is quite straightforward.

Adding the jOOQ open source edition via Maven

From the Maven perspective, adding the jOOQ open source edition into a Spring Boot application starts from the pom.xml file. The jOOQ open source edition dependency is available at Maven Central (https://mvnrepository.com/artifact/org.jooq/jooq) and can be added like this:

<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>jooq</artifactId>
  <version>...</version> <!-- optional -->
</dependency>

Alternatively, if you prefer a Spring Boot starter, then rely on this one:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jooq</artifactId>
</dependency>

If you are a fan of Spring Initializr (https://start.spring.io/), then just select the jOOQ dependency from the corresponding list of dependencies.

That's all! Note that <version> is optional. If <version> is omitted, then Spring Boot will properly choose the jOOQ version compatible with the Spring Boot version used by the application. Nevertheless, whenever you want to try a different jOOQ version, you can simply add <version> explicitly. At this point, the jOOQ open source edition is ready to be used to start developing the persistence layer of an application.

Adding the jOOQ open source edition via Gradle

From the Gradle perspective, adding the jOOQ open source edition into a Spring Boot application can be accomplished via a plugin named gradle-jooq-plugin (https://github.com/etiennestuder/gradle-jooq-plugin/). This can be added to your build.gradle, as follows:

plugins {
  id 'nu.studer.jooq' version ...
}

Of course, if you rely on Spring Initializr (https://start.spring.io/), then just select a Gradle project, add the jOOQ dependency from the corresponding list of dependencies, and once the project is generated, add the gradle-jooq-plugin plugin. As you'll see in the next chapter, using gradle-jooq-plugin is quite convenient for configuring the jOOQ Code Generator.

Adding a jOOQ free trial (commercial edition)

Adding a free trial commercial edition of jOOQ (jOOQ Express, Professional, and Enterprise editions) to a Spring Boot project (overall, in any other type of project) requires a few preliminary steps. Mainly, these steps are needed because the jOOQ free trial commercial distributions are not available on Maven Central, so you have to manually download the one that you need from the jOOQ download page (https://www.jooq.org/download/). For instance, you can choose the most popular one, the jOOQ Professional distribution, which comes packaged as a ZIP archive. Once you have unzipped it, you can install it locally via the maven-install command. You can find these steps exemplified in a short movie in the bundled code (Install_jOOQ_Trial.mp4).

For Maven applications, we use the jOOQ free trial identified as org.jooq.trial (for Java 17) or org.jooq.trial-java-{version}. When this book was written, the version placeholder could be 8 or 11, but don't hesitate to check for the latest updates. We prefer the former, so in pom.xml, we have the following:

<dependency>
  <groupId>org.jooq.trial-java-8</groupId>
  <artifactId>jooq</artifactId>
  <version>...</version>
</dependency>

For Java/Gradle, you can do it, as shown in the following example, via gradle-jooq-plugin:

jooq {
  version = '...'
  edition = nu.studer.gradle.jooq.JooqEdition.TRIAL_JAVA_8
}

For Kotlin/Gradle, you can do it like this:

jooq {
  version.set(...)
  edition.set(nu.studer.gradle.jooq.JooqEdition.TRIAL_JAVA_8)
}

In this book, we will use jOOQ open source in applications that involve MySQL and PostgreSQL, and jOOQ free trial in applications that involve SQL Server and Oracle. These two database vendors are not supported in jOOQ open source.

If you're interested in adding jOOQ in a Quarkus project then consider this resource: https://github.com/quarkiverse/quarkus-jooq

Injecting DSLContext into Spring Boot repositories

One of the most important interfaces of jOOQ is org.jooq.DSLContext. This interface represents the starting point of using jOOQ, and its main goal is to configure the behavior of jOOQ when executing queries. The default implementation of this interface is named DefaultDSLContext. Among the approaches, DSLContext can be created via an org.jooq.Configuration object, directly from a JDBC connection (java.sql.Connection), a data source (javax.sql.DataSource), and a dialect needed for translating the Java API query representation, written via jOOQ into a database-specific SQL query (org.jooq.SQLDialect).

Important Note

For java.sql.Connection, jOOQ will give you full control of the connection life cycle (for example, you are responsible for closing this connection). On the other hand, connections acquired via javax.sql.DataSource will be automatically closed after query execution by jOOQ. Spring Boot loves data sources, therefore the connection management is already handled (acquire and return connection from/to the connection pool, transaction begin/commit/rollback, and so on).

All jOOQ objects, including DSLContext, are created from org.jooq.impl.DSL. For creating a DSLContext, the DSL class exposes a static method named using(), which comes in several flavors. Of these, the most notable are listed next:

// Create DSLContext from a pre-existing configuration
DSLContext ctx = DSL.using(configuration);
// Create DSLContext from ad-hoc arguments
DSLContext ctx = DSL.using(connection, dialect);

For example, connecting to the MySQL classicmodels database can be done as follows:

try (Connection conn = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/classicmodels", 
    "root", "root")) {
  DSLContext ctx = 
    DSL.using(conn, SQLDialect.MYSQL);
  ...
} catch (Exception e) {
  ...
}

Alternatively, you can connect via a data source:

DSLContext ctx = DSL.using(dataSource, dialect);

For example, connecting to the MySQL classicmodels database via a data source can be done as follows:

DSLContext getContext() {
  MysqlDataSource dataSource = new MysqlDataSource();
  dataSource.setServerName("localhost");
  dataSource.setDatabaseName("classicmodels");
  dataSource.setPortNumber("3306");
  dataSource.setUser(props.getProperty("root");
  dataSource.setPassword(props.getProperty("root");
  return DSL.using(dataSource, SQLDialect.MYSQL);
}

But Spring Boot is capable of automatically preparing a ready-to-inject DSLContext based on our database settings. For example, Spring Boot can prepare DSLContext based on the MySQL database settings specified in application.properties:

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/
                 classicmodels?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=root
spring.jooq.sql-dialect=MYSQL

Once Spring Boot detects the jOOQ presence, it uses the preceding settings to create org.jooq.Configuration, which is used to prepare a ready-to-inject DSLContext.

Important Note

While DSLContext has a high degree of configurability and flexibility, Spring Boot performs only the minimum effort to serve a default DSLContext that can be injected and used immediately. As you'll see in this book (but especially in the official jOOQ manual – https://www.jooq.org/doc/latest/manual/), DSLContext has tons of configurations and settings that allow taking control of almost anything that happens with our SQL statements.

The DSLContext object provided by Spring Boot can be easily injected into our persistence repositories. For instance, the next snippet of code serves such a DSLContext object directly into ClassicModelsRepository:

@Repository
public class ClassicModelsRepository {
  private final DSLContext ctx;
  public ClassicModelsRepository(DSLContext ctx) {
    this.ctx = ctx;
  }
  ...
}

Don't conclude here that the application needs to keep a reference to DSLContext. That can still be used directly in a local variable, as you saw earlier (which means that you can have as many DSLContext objects as you want). It only means that, in a Spring Boot application, for most common scenarios, it is more convenient to simply inject it as shown previously.

Internally, jOOQ can use java.sql.Statement or PreparedStatement. By default, and for very good and strong reasons, jOOQ uses PreparedStatement.

Typically, the DSLContext object is labeled as ctx (used in this book) or dsl. But, other names such as dslContext, jooq, and sql are also good choices. Basically, you name it.

Okay, so far, so good! At this point, we have access to DSLContext provided out of the box by Spring Boot, based on our settings from application.properties. Next, let's see DSLContext at work via jOOQ's query DSL API.

Using the jOOQ query DSL API to generate valid SQL

Using the jOOQ query DSL API to generate valid SQL is a good start for exploring the jOOQ world. Let's take a simple SQL statement, and let's express it via jOOQ. In other words, let's use the jOOQ query DSL API to express a given SQL string query into the jOOQ object-oriented style. Consider the next SQL SELECT written in the MySQL dialect:

SELECT * FROM `office` WHERE `territory` = ?

The SQL, SELECT * FROM `office` WHERE `territory` = ?, is written as a plain string. This query can be generated by jOOQ if it is written via the DSL API, as follows (the value of the territory binding variable is supplied by the user):

ResultQuery<?> query = ctx.selectFrom(table("office"))
  .where(field("territory").eq(territory));

Alternatively, if we want to have the FROM clause closer to SQL look, then we can write it as follows:

ResultQuery<?> query = ctx.select()
  .from(table("office"))                  
  .where(field("territory").eq(territory));

Most schemas are case-insensitive, but there are databases such as MySQL and PostgreSQL that prefer mostly lowercase, while others such as Oracle prefer mostly uppercase. So, writing the preceding query in Oracle style can be done as follows:

ResultQuery<?> query = ctx.selectFrom(table("OFFICE"))
  .where(field("TERRITORY").eq(territory));

Alternatively, you can write it via an explicit call of from():

ResultQuery<?> query = ctx.select()
  .from(table("OFFICE"))                  
  .where(field("TERRITORY").eq(territory));

The jOOQ fluent API is a piece of art that looks like fluent English and, therefore, is quite intuitive to read and write.

Reading the preceding queries is pure English: select all offices from the OFFICE table where the TERRITORY column is equal to the given value.

Pretty soon, you'll be amazed at how fast you can write these queries in jOOQ.

Important Note

As you'll see in the next chapter, jOOQ can generate a Java-based schema that mirrors the one in the database via a feature named the jOOQ Code Generator. Once this feature is enabled, writing these queries becomes even simpler and cleaner because there will be no need to reference the database schema explicitly, such as the table name or the table columns. Instead, we will reference the Java-based schema.

And, thanks to the Code Generator feature, jOOQ makes the right choices for us upfront almost everywhere. We no longer need to take care of queries' type-safety and case-sensitivity, or identifiers' quotation and qualification.

The jOOQ Code Generator atomically boosts the jOOQ capabilities and increases developer productivity. This is why using the jOOQ Code Generator is the recommended way to exploit jOOQ. We will tackle the jOOQ Code Generator in the next chapter.

Next, the jOOQ query (org.jooq.ResultQuery) must be executed against the database, and the result set will be mapped to a user-defined simple POJO.

Executing the generated SQL and mapping the result set

Executing the generated SQL and mapping the result set to a POJO via jOOQ can be done via the fetching methods available in the jOOQ API. For instance, the next snippet of code relies on the fetchInto() flavor:

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

What happened there?! Where did ResultQuery go? Is this black magic? Obviously not! It's just that jOOQ has immediately fetched results after constructing the query and mapped them to the Office POJO. Yes, the jOOQ's fetchInto(Office.class) or fetch().into(Office.class) would work just fine out of the box. Mainly, jOOQ executes the query and maps the result set to the Office POJO by wrapping and abstracting the JDBC complexity in a more object-oriented way. If we don't want to immediately fetch the results after constructing the query, then we can use the ResultQuery object like this:

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

The Office POJO is available in the code bundled with this book.

Important Note

jOOQ has a comprehensive API for fetching and mapping a result set into collections, arrays, maps, and so on. We will detail these aspects later on in Chapter 8, Fetching and Mapping.

The complete application is named DSLBuildExecuteSQL. Since this can be used as a stub application, you can find it available for Java/Kotlin in combination with Maven/Gradle. These applications (along with, in fact, all the applications in this book) use Flyway for schema migration. As you'll see later, Flyway and jOOQ make a great team.

So, let's quickly summarize this chapter before moving on to exploit the astonishing jOOQ Code Generator feature.

Summary

Note that we barely scratched the surface of jOOQ's capabilities by using it only for generating and executing a simple SQL statement. Nevertheless, we've already highlighted that jOOQ can generate valid SQL against different dialects and can execute and map a result set in a straightforward manner.

In the next chapter, we learn how to trust jOOQ more by increasing its level of involvement. jOOQ will generate type-safe queries, POJOs, and DAOs on our behalf.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Write complex, type-safe, and dynamic SQL using the powerful jOOQ API
  • Tackle complex persistence tasks, such as lazy fetching, R2DBC, transactions, and batching while sustaining high traffic in your modern Java applications
  • Use a comprehensive SPI to shape and extend jOOQ according to your needs

Description

jOOQ is an excellent query builder framework that allows you to emulate database-specific SQL statements using a fluent, intuitive, and flexible DSL API. jOOQ is fully capable of handling the most complex SQL in more than 30 different database dialects. jOOQ Masterclass covers jOOQ from beginner to expert level using examples (for MySQL, PostgreSQL, SQL Server, and Oracle) that show you how jOOQ is a mature and complete solution for implementing the persistence layer. You’ll learn how to use jOOQ in Spring Boot apps as a replacement for SpringTemplate and Spring Data JPA. Next, you’ll unleash jOOQ type-safe queries and CRUD operations via jOOQ’s records, converters, bindings, types, mappers, multi-tenancy, logging, and testing. Later, the book shows you how to use jOOQ to exploit powerful SQL features such as UDTs, embeddable types, embedded keys, and more. As you progress, you’ll cover trending topics such as identifiers, batching, lazy loading, pagination, and HTTP long conversations. For implementation purposes, the jOOQ examples explained in this book are written in the Spring Boot context for Maven/Gradle against MySQL, Postgres, SQL Server, and Oracle. By the end of this book, you’ll be a jOOQ power user capable of integrating jOOQ in the most modern and sophisticated apps including enterprise apps, microservices, and so on.

What you will learn

Enable the jOOQ Code Generator in any combination of Java and Kotlin, Maven and Gradle Generate jOOQ artifacts directly from database schema, or without touching the real database Use jOOQ DSL to write and execute a wide range of queries for different databases Understand jOOQ type-safe queries, CRUD operations, converters, bindings, and mappers Implement advanced SQL concepts such as stored procedures, derived tables, CTEs, window functions, and database views Implement jOOQ multi-tenancy, tuning, jOOQ SPI, logging, and testing

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Aug 19, 2022
Length 764 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781800566897
Category :
Languages :

Table of Contents

26 Chapters
Preface Chevron down icon Chevron up icon
Part 1: jOOQ as a Query Builder, SQL Executor, and Code Generator Chevron down icon Chevron up icon
Chapter 1: Starting jOOQ and Spring Boot Chevron down icon Chevron up icon
Chapter 2: Customizing the jOOQ Level of Involvement Chevron down icon Chevron up icon
Part 2: jOOQ and Queries Chevron down icon Chevron up icon
Chapter 3: jOOQ Core Concepts Chevron down icon Chevron up icon
Chapter 4: Building a DAO Layer (Evolving the Generated DAO Layer) Chevron down icon Chevron up icon
Chapter 5: Tackling Different Kinds of SELECT, INSERT, UPDATE, DELETE, and MERGE Chevron down icon Chevron up icon
Chapter 6: Tackling Different Kinds of JOINs Chevron down icon Chevron up icon
Chapter 7: Types, Converters, and Bindings Chevron down icon Chevron up icon
Chapter 8: Fetching and Mapping Chevron down icon Chevron up icon
Part 3: jOOQ and More Queries Chevron down icon Chevron up icon
Chapter 9: CRUD, Transactions, and Locking Chevron down icon Chevron up icon
Chapter 10: Exporting, Batching, Bulking, and Loading Chevron down icon Chevron up icon
Chapter 11: jOOQ Keys Chevron down icon Chevron up icon
Chapter 12: Pagination and Dynamic Queries Chevron down icon Chevron up icon
Part 4: jOOQ and Advanced SQL Chevron down icon Chevron up icon
Chapter 13: Exploiting SQL Functions Chevron down icon Chevron up icon
Chapter 14: Derived Tables, CTEs, and Views Chevron down icon Chevron up icon
Chapter 15: Calling and Creating Stored Functions and Procedures Chevron down icon Chevron up icon
Chapter 16: Tackling Aliases and SQL Templating Chevron down icon Chevron up icon
Chapter 17: Multitenancy in jOOQ Chevron down icon Chevron up icon
Part 5: Fine-tuning jOOQ, Logging, and Testing Chevron down icon Chevron up icon
Chapter 18: jOOQ SPI (Providers and Listeners) Chevron down icon Chevron up icon
Chapter 19: Logging and Testing Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela