Posted in Spring Boot Spring JPA

Spring Boot Hikari Connection Pool Configurations

Hikari Connection Pool Here in this Spring Boot application example, I am going to show you how to use Hikari connection pool to use dedicated HikariDataSource instead of the use of database specific datasource. Hikari connection pool commonly known as HikariCP is extremely fast, light-weight, simple and production ready JDBC connection pool.

Continue Reading... Spring Boot Hikari Connection Pool Configurations
Posted in Spring JPA

Spring Boot Composite Primary Key Example

Composite Primary Key Composite primary key is a combination of two or more columns in a table. So instead of a single column to be a primary key, more than one column or field is made to be a primary key to uniquely identify the rows in a given table. Let’s say you have created a table called user in your database…

Continue Reading... Spring Boot Composite Primary Key Example
Posted in Spring Boot Spring JPA

Spring Boot Data JPA Entity DTO Mapping Using MapStruct

Introduction In this example I will show you how to convert entity class to DTO (Data Transfer Object) class and DTO class to entity class using MapStruct. So, MapStruct will map entity class to DTO class or vice versa. This example will test both from RESTful webservices and standalone main class. Spring Boot provides CommandLineRunner interface to run the project…

Continue Reading... Spring Boot Data JPA Entity DTO Mapping Using MapStruct
Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasPermission Security Using Spring Boot Data JPA

Introduction The ability of hasPermission() method in Spring Boot Security applications is to determine the accessibility of a particular user for the application. The permission of an access can be read, write, etc. So, a particular user has defined set of access permission by which a user can perform certain activities in the application. The most useful annotation @PreAuthorize, which…

Continue Reading... PreAuthorize HasPermission Security Using Spring Boot Data JPA
Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasRole Security Using Spring Boot Data JPA

Table of Contents Introduction Where is @PreAuthorize applicable? Prerequisites Project Setup MySQL Table Data Application Config Entity Classes Repository Interfaces Service Class REST Controller Class Security Config Spring Boot Main Class Testing Spring Security – PreAuthorize hasRole Source Code Introduction PreAuthorize hasRole Spring security will determine whether a user can invoke a method or not based on his/her role. hasRole()…

Continue Reading... PreAuthorize HasRole Security Using Spring Boot Data JPA
Posted in Angular Spring Boot Spring JPA Spring REST

Angular Spring Boot REST API CRUD Example

Introduction In this tutorial I am going to show you how to build Spring Boot Angular CRUD Application. CRUD is an acronym and stands for Create, Read, Update and Delete operations performed through an application or APIs. Using Spring Boot application I will build REST APIs which will be used to perform CRUD operations on server side resources. The Angular…

Continue Reading... Angular Spring Boot REST API CRUD Example
Posted in Spring Boot Spring JPA

Bootstrap AJAX Spring Boot Pagination

Introduction In this tutorial I will use Spring Data JPA Pageable to build REST API for pagination in Spring Boot applications. Here, I am going to show you how to build pagination using Bootstrap jQuery – AJAX with Spring Boot applications. Using jQuery – AJAX, you don’t need to load or fetch all records from server side, and you are…

Continue Reading... Bootstrap AJAX Spring Boot Pagination
Posted in Spring Boot Spring JPA

Bulk Delete Using Spring JPA CriteriaDelete

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

Continue Reading... Bulk Delete Using Spring JPA CriteriaDelete
Posted in Spring Boot Spring JPA

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…

Continue Reading... Bulk Update Using Spring JPA CriteriaUpdate
Posted in Spring Boot Spring JPA Spring REST

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…

Continue Reading... How To Log Online User Activity In Spring Boot Applications