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…

Posted in Spring JPA

Spring Boot Composite Primary Key Example

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…

Posted in Spring Boot Spring JPA

Spring Boot Data JPA Entity DTO Mapping Using MapStruct

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…

Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasPermission 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…

Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasRole Security Using Spring Boot Data JPA

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…

Posted in Angular Spring Boot Spring JPA Spring REST

Angular Spring Boot REST API CRUD Example

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…

Posted in Spring Boot Spring JPA

Bootstrap AJAX Spring Boot Pagination

Introduction 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…

Posted in Spring Boot Spring JPA

Bulk Delete Using Spring JPA CriteriaDelete

Introduction 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…

Posted in Spring Boot Spring JPA

Bulk Update Using Spring JPA CriteriaUpdate

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…

Posted in Spring Boot Spring JPA Spring REST

How To Log Online User Activity In Spring Boot Applications

Introduction Spring Data JPA provides multiple ways of selecting or fetching data from database server and one of the ways is using @NamedQuery or @NamedQueries. @NamedQuery and @NamedQueries can be created using XML configuration, external properties file or using Java based annotation config. Spring Data JPA supports both JPQL and SQL native named queries. Here…

Posted in Spring Boot Spring JPA

Spring Data JPA @NamedQuery and @NamedQueries Example

Introduction The tutorial, GraphQL Spring MySQL CRUD example will show you how to build CRUD (Create, Read, Update, Delete) operations using GraphQL with Spring Boot framework. We will use MySQL database server for storing data and Spring Data JPA to perform database activities. My previous tutorials on GraphQL explained about how to wrap REST APIs…

Posted in GraphQL MySQL Spring Boot Spring JPA

GraphQL Spring MySQL CRUD Example

Introduction In this example you will see how to work with IN clause with WHERE condition in SQL statement in Spring Data JPA. I will use MySQL server for this example. I will fetch selected rows or multiple rows selection as well as I will delete selected rows or multiple rows deletion from the table…

Posted in MySQL Spring JPA Spring REST

Spring Data JPA IN Clause Example With WHERE Condition