Bulk Update Using Spring JPA CriteriaUpdate

Criteria Update The new feature bulk update operation in Criteria API was added in JPA 2.1. I will show you an example how to perform bulk update using Spring JPA CriteriaUpdate. The CriteriaUpdate interface can be used to implement bulk update operations. Update operations performed through CriteriaUpdate interface are directly mapped to database update operations. Hence the persistent context is…

Spring JdbcNamedParameterTemplate Junit Mockito

Introduction In the tutorial, Spring NamedParameterJdbcTemplate and MapSqlParameterSource Example, I had shown how to save new record in the database and how to fetch record from database. Here I am going to show you how to mock Spring JdbcNamedParameterTemplate SqlParameterSource with Junit Mockito. I am going to use Junit 5 framework for this example. I am also using Mockito framework…

Spring Boot Profile Based Logging

Profile Based Logging Here in this example, I am going to show you how to create Spring Boot profile based logging. For any applications logging is an important things which will help you to debug through your application errors or issues and you can fix them easily by analyzing those errors or issues from the log files. Let’s say you…

Spring Boot Application Over HTTPS

Introduction In this example I am going to show you how to start your spring boot application on HTTPS protocol. HTTPS is a secured protocol, whereas HTTP is unsecured protocol. So the data passed over the network using HTTPS protocol are generally encrypted data. The application which I am going to build is in the local environment and for this…

Spring Security Pre-Authentication with Spring Data JPA

Introduction In this example I am going to show you Spring Security Pre-authentication hasrole with Spring Data JPA. In my another example I had shown the similar example on Spring Security Pre-Authentication with Spring JDBC Template. There are situations where you want to use Spring Security for authorization, but the user has already been reliably authenticated by some external system…

How To Log Online User Activity In Spring Boot Applications

Introduction Here I am going to build a system to log online user activity in Spring Boot applications using HandlerInterceptor interface. As an application owner you may want to track your user activities, such as, which page they are accessing, from where requests were made to your application, from which pages to which pages they are moving, etc. If your…

Call Spring REST APIs Concurrently Using Java Completable Future

REST Services In this tutorial I am going to show you how to call Spring REST APIs concurrently using Java CompletableFuture. So basically REST service APIs will be invoked parallelly and in parallel execution the response time will be very less. I am going to show you how to call REST APIs concurrently using Java 8 or later’s new feature…

Download Large File Using Spring REST API

File Download Here in this tutorial I am going to show you how to download large file using Spring REST API. Generally when you download a file, your file is stored into file system or you load it into memory as a byte array. This is not a problem when you deal with a small file but when you download…

Spring Boot AJAX jQuery to check User Availability Instantly

Introduction Here in this tutorial I am going to show you how to use AJAX technique using jQuery with Spring Boot application to check user availability instantly without refreshing the web page. I am going to use Thymeleaf template in Spring Boot application. I will use Spring REST to create REST API endpoint which will be called from jQuery code….

Spring Cloud Gateway Security with JWT (JSON Web Token)

Spring Cloud Gateway Security In this tutorial I am going to show you an example on Spring Cloud Gateway Security with JWT. JSON Web Tokens (JWT) are an open, industry standard RFC 7519 method for representing claims securely between two parties. JWT.IO allows you to decode, verify and generate JWT. The Spring Cloud Gateway sits in front of your microservices…