Spring Data JPA @NamedQuery and @NamedQueries Example

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 I am going to show you examples on @NamedQuery and @NamedQueries. I am also going to use named parameter and positional parameter in the named queries. In XML configuration you need to use <named-query/> and for…

Continue

GraphQL Spring MySQL CRUD 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 instead of converting them into GraphQL APIs. I explained on this using Spring Boot and NodeJS technologies.

Continue

Spring Data JPA IN Clause Example with WHERE Condition

Introduction In this example we will see how to work with IN clause with WHERE condition in SQL statement in Spring Data JPA. We will use MySQL server for this example. We will fetch selected rows or multiple rows selection as well as we will delete selected rows or multiple rows deletion from the table using IN operator with WHERE clause. We will use Spring transaction because we want to rollback our changes from database if any issue occurs during row deletion. The IN operator allows us to specify multiple…

Continue

How to work with IN, OUT and INOUT Parameters in Stored Procedures using Spring Data JPA

Introduction In this tutorial we will see how to work with IN, OUT and INOUT parameters in Stored Procedure using Spring Data JPA. We will also call a stored procedure having no parameter at all. I am going to use MySQL server, so there may be some limitations on MySQL server or there may be some limitations on Spring Data JPA itself on calling the stored procedure but I will at least show you the work around how to call stored procedures in different ways depending upon the type of…

Continue

How to map Custom Query Results into DTO in Spring Data JPA

In this tutorial we will see how to map custom query results into DTO in Spring Data JPA. Situations occur while you are unable to return the entity object(s) as results from your Spring Data JPA Repository and instead you are writing custom query or native query for your business requirements. So in such situations you need to convert result into DTO (data Trasfer Object). We will use @Query annotation to create custom queries in Spring Data JPA. It is also advisable to use DTO instead of entity class or…

Continue

Spring Boot jQuery AJAX CRUD Example

Introduction In this example we will see an example on Spring Boot jQuery AJAX CRUD. CRUD is an acronym for four operations such as Create, Read, Update and Delete. We are going to perform CRUD operations on company details. We will use here MySQL database to store company details information. We will perform each operation asynchronously through AJAX technique using jQuery on client side and Spring Boot with Spring Data JPA in server side. We will create here REST APIs using Spring Boot and call those REST APIs through jQuery…

Continue

Spring Boot Data JPA Left, Right, Inner and Cross Join Examples on Three Tables

Introduction In this guide we will walk through Spring Boot Data JPA left, right, inner and cross join examples on three tables. In pas we have seen similar example on two tables but I got some requests on how to perform similar joins on three tables. Therefore I am going to show you how to perform joins – left, right, inner, cross – on three tables. We are going to build custom query using @Query annotation to fetch the data from database tables. We also fetch the columns which are required to…

Continue

Spring Boot Data JPA CRUD Example

Introduction We will see here Spring Boot Data JPA CRUD example. CRUD means Create Read Update and Delete operations. We will use in-memory h2 database in order to perform CRUD operations in database. We have other example on Spring Data JPA CRUD example but the application does not use Spring Boot. In this example, we will use Spring Boot. We will use Spring REST controller to expose our CRUD operations onto REST API.

Continue

Download file using React and Spring Boot

Introduction In this post you will see how to download file using React and Spring Boot. There are situations where you need to download file from server or you need to generate report from database and download it. This example may help you in that situation. Here I will fetch records from database and download in a JSON format. As a server side technology I will use Spring Boot and in client side I will use React JS.

Continue

Download file using Angular and Spring Boot

Introduction In this post I will show you how to download file using Angular 7/8/10 and Spring Boot. There are situations when you need to download file from server or you need to generate report from database and download it. This example may help you in such situation. I will build the Spring Boot application using both maven and gradle. Here I will fetch records from database and download in a JSON format. As a server side technology we will use Spring Boot and in client side we will use…

Continue