In this Spring MVC tutorial, you will learn how to read HTTP Request Header in the Rest Controller class of your Application. To read HTTP Request Header in Spring MVC application we use @RequestHeader annotation. @RequestHeader(value=”Accept”) String acceptHeader Reading HTTP Request Header For example, let’s assume we need to create a method in our Rest…

Read More Read HTTP Request Header in Spring MVC

In this Swagger tutorial, I am going to share with you how to add Contact and API information to your RESTful Web Service documentation created with Swagger. When adding Swagger to our RESTful Web Service, we usually create a new configuration Java Class which is then annotated with @Configuration annotation. Below is an example of…

Read More REST API Contact and ApiInfo with Swagger

In this tutorial, you will learn how to add Swagger or an OpenAPI support to your Spring Boot project so that you can start documenting your REST API. To be able to follow this tutorial you will need to have your REST API Spring Boot project created. If you do not have one, here is…

Read More How to Add Swagger to a Spring Boot REST API Project

In this tutorial, you will learn how to deal with an infinite recursion problem or circular reference which takes place when you try to return an Object with Bidirectional Relationships in the body of HTTP Response. Infinite Recursion Problem Let’s have a look at an example which will cause an Infinite Recursion problem in our RESTful Web…

Read More Infinite Recursion in Objects with Bidirectional Relationships

In this short tutorial, you will learn how to rollback a database change using @Transactional annotation in your RESTful Web Service built with Spring MVC and JPA. Rollback with @Transactional Annotation Sometimes if an error takes place in our RESTful Web Service we want to rollback the changes made. For changes to be rolled back…

Read More Rollback Using @Transactional in Spring with JPA

In this short Spring Data JPA tutorial, you will learn how to create a JPA Native SQL Query to select specific columns only. JPA Native SQL Query to Select Specific Columns Below is an example of JPA Native Query that selects from a database table called Users only two columns: first_name and, last_name @Query(value=”select first_name,…

Read More Select Specific Columns with JPA Native Query

In this short Spring Data JPA tutorial, you will learn how to use the LIKE % expression in a Native SQL Query. When using advanced SQL LIKE expression the % sign in the SQL query would represent zero, one or multiple characters. Let’s have a look at the Native JPA SQL Query that uses advanced…

Read More How to Use LIKE % Expression in JPA SQL Query

In this short Spring Boot tutorial, I am going to share with you how to make Spring Boot app show Hibernate SQL Queries. Enable Hibernate SQL Queries Logging To show hibernate SQL queries in Spring Boot log file you will need to update the application.properties file with the following details: logging.level.org.hibernate.SQL=debug Show SQL Values Additionally,…

Read More Show Hibernate SQL Query in Spring Boot

In this short Spring Data JPA tutorial, you will learn how to write a Native UPDATE SQL query. Let’s assume you need to run the following SQL query: update users u set u.EMAIL_VERIFICATION_STATUS = ‘true’ where u.USER_ID = ‘5JwQBHd1mL73XEg8S2e2w4ITn9gOW4’ I assume you will not want to hardcode the values of EMAIL_VERIFICATION_STATUS and USER_ID into SQL…

Read More Spring Data JPA Native UPDATE SQL Query

In this blog post, I am going to list commonly used POM.XML dependencies for building RESTful Web services with Spring Boot and Spring MVC. The list of below dependencies is not complete and will depend on the functionality you need your RESTful Web Services to support. But if you are building a simple REST API…

Read More Common POM.XML Dependencies for RESTful Web Services