In this Engineering With Java newsletter edition, we have hand-picked some interesting Java and Spring articles worth reading. These articles include topics such as hibernate, completable future, functional interfaces in JUnit, Query S3 data with spring boot, etc.
🚀 Unlock Your Path to Success with the Ultimate Everything Bundle! 🚀
Introducing the Everything Bundle — your one-stop solution to mastering Java, Spring Boot, SQL, acing interviews, and securing certifications!
1. Hibernate load() and get(): What’s the Difference?
The article from Java Code Geeks explains the differences between Hibernate's
load()
andget()
methods.load()
: Returns a proxy object, deferring database access until a property is accessed, and throws anObjectNotFoundException
if the entity doesn't exist.get()
: Immediately hits the database to return the actual entity ornull
if the entity isn't found.load()
is useful for lazy initialization, whileget()
is suited for immediate access to the entity's data.
2. How to Make Multiple REST Calls in CompletableFuture
The article from Java Code Geeks explains how to use Java's
CompletableFuture
for making multiple REST calls in parallel.This improves performance by reducing wait times and efficiently utilizing system resources.
It demonstrates the process with code examples, including handling asynchronous HTTP requests, aggregating responses, and managing errors using methods like
exceptionally
andhandle
.This approach enhances responsiveness and maintains code readability and robustness.
3. Guide to JUnit 5 Functional Interfaces
The article on Reflectoring discusses how to use functional interfaces with JUnit 5. It covers the basics of functional interfaces and their benefits, such as making test code more concise and readable.
The article demonstrates how to use the
Executable
interface withAssertions.assertThrows
andDynamicTest.dynamicTest
.It also explains how to implement custom functional interfaces for specific testing needs, showcasing the flexibility and power of combining JUnit 5 with Java functional programming features.
🚀 Grokking the Java Interview 🚀
Crack your Java interview by preparing important topics and mastering key concepts in a guided and structured way in a short time.
4. Java’s wait(), notify(), and notifyAll() Explained
Inter-thread communication and synchronization are crucial for managing concurrency.Java provides
wait()
,notify()
, andnotifyAll()
methods to handle these tasks.Multiple threads can improve performance but lead to race conditions and deadlocks when accessing shared resources.
Uses the
synchronized
keyword to control thread access, ensuring only one thread accesses a resource at a time.wait(): Causes a thread to wait until another thread invokes
notify()
ornotifyAll()
; notify(): Wakes up a single waiting thread.; notifyAll(): Wakes up all waiting threads.
5. Java Interview Study Guide: Comprehensive Features List
This cheat sheet includes major features for each Java version, from its humble beginnings in 1996 to the latest features in Java 21 (September 2023).
It is a good list to refer to while studying for Java interviews.
6. Java: Demystifying The Stream API
This article covers the use of Java's Stream API for processing collections in a functional and declarative style.
It explains the core operations of the Stream API—map, filter, and reduce—detailing their functions and how they are used. The article also contrasts streams with traditional for-loops, discussing the advantages of readability and potential parallelism.
It further explores intermediate and terminal operations and highlights the performance benefits of lazy execution and parallel processing.
7. Dynamic watermarking on the JVM
This article discusses how to dynamically watermark images using Java. It explains the concept of digital watermarking, which is embedding information into images to indicate ownership.
The author demonstrates how to implement this in a Jakarta EE-based web application using the Java 2D API.
The process involves reading the original image and watermark, drawing the watermark on the image, and writing the result to the response output stream. This approach avoids pre-processing images and offers a flexible, real-time solution.
8. Upload Files With GraphQL in Java
The article from Baeldung discusses how to implement file uploads using GraphQL in a Java Spring Boot application.
GraphQL provides an alternative to traditional REST APIs by offering a streamlined approach. However, integrating file uploads in GraphQL with Spring Boot requires special consideration due to GraphQL's handling of binary data.
One effective approach is to handle file uploads through dedicated HTTP endpoints and then link these uploads to GraphQL mutations using identifiers like URLs or IDs.
This method simplifies handling large files and ensures efficient application performance.
9. Practical Guide to Getting Started with Spring Boot and Netflix DGS
The article introduces GraphQL and Netflix DGS within the context of Spring Boot, aiming to build scalable GraphQL services. Key points include setting up GraphQL queries and mutations using DGS annotations, integrating with Spring Data JPA for database operations, and creating custom contexts for enhanced functionality.
The article provides detailed steps for schema creation, entity mapping, repository setup, and querying/mutation handling. It emphasizes practical implementation through a simple e-commerce example with relational database interactions.
10. Using Amazon Athena With Spring Boot to Query S3 Data
This explains how to integrate and use Amazon Athena with Spring Boot applications. It covers setting up dependencies, configuring the application properties for connecting to Athena, and executing queries using the Athena JDBC driver.
The tutorial emphasizes creating a data source configuration for Athena in Spring Boot, managing credentials securely, and performing SQL queries against data stored in Amazon S3 via Athena.
It also discusses handling query results and potential optimizations for better performance when querying large datasets.
🚀 Ace Your Next System Design Interview 🚀
Taught by a best-selling author, everything you need to take your system design skills to the next level.