Deleting Products
Start course
2h 34m

In this course, we will learn the concepts of microservice and spring framework with a focus on Spring Boot.

Learning Objectives

  • Understanding Spring Boot

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud


  • Basic Java knowledge

Hello dear friends?

In this video, we will delete products from our projects Admin Product List page. So, let's begin. Before I begin, I must clarify that when we delete a product, we must also delete all bills on our project. In large projects, we achieve this via database triggers. However, my goal with this project is to educate using the Spring framework and to create CRUD JPA operations. Therefore, I will only delete products from my database. However, keep in mind that if you delete a product from your database, you must also delete all data associated with the product. All right, let's begin. First, open AdminController. We need a DeleteProduct method. We will get ID from the form, so we have to use the PathVariable. Now, let's adjust the map path, delete product, and we also have to add id as a parameter. After deletion we will redirect the page to the AdminProductList page.

In fact, in my projects I prefer to carry out this operation in JavaScript and only then can we fade a selected row from the table. However, because I will be using JavaScript with stock control, I will delete while refreshing the page. Now open ProductServiceImplementation. Now to delete we will override the deleteProduct method. This method we'll call the deleteById method of the productRepository, which will be enough for the time being. Now let's return to the admin controller. In delete method only, we will call deleteById method a productservice. Okay, done. Let's add this delete action to the AdminProductList page. Okay, got it. Let's try, Run project. Log in with admin. Go to the Add Product page. Let's add a new product. Now let's delete this one and look our computer was deleted. All right. This was a nice short video and we are complete on it. In the following video, we will implement the product update operation. So, I'll see you there.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.