Class OrderSeeder
java.lang.Object
com.needleandstitch.pavuk.data.OrderSeeder
- All Implemented Interfaces:
org.springframework.boot.CommandLineRunner
@Component
@Order(13)
public class OrderSeeder
extends Object
implements org.springframework.boot.CommandLineRunner
Seeder class for initializing default orders in the database.
This class checks that certain orders are present in the database and adds them if they are missing.
The seeding process is triggered during application startup.
- Since:
- 15.12.2024
- Version:
- 1.0.0
- Author:
- Needle & Stitch
-
Constructor Summary
ConstructorsConstructorDescriptionOrderSeeder
(OrderRepository orderRepository, CustomerRepository customerRepository, ClothingItemRepository clothingItemRepository, ShippingInfoRepository shippingInfoRepository) Constructs a new OrderSeeder with the specified repository. -
Method Summary
-
Constructor Details
-
OrderSeeder
public OrderSeeder(OrderRepository orderRepository, CustomerRepository customerRepository, ClothingItemRepository clothingItemRepository, ShippingInfoRepository shippingInfoRepository) Constructs a new OrderSeeder with the specified repository.- Parameters:
orderRepository
- The repository used for interacting with the Order entitiescustomerRepository
- The repository used for interacting with the Customer entitiesclothingItemRepository
- The repository used for interacting with the ClothingItem entitiesshippingInfoRepository
- The repository used for interacting with the ShippingInfo entities
-
-
Method Details
-
run
Seeds the database with default orders if they are not already present.- Specified by:
run
in interfaceorg.springframework.boot.CommandLineRunner
- Parameters:
args
- The command-line arguments passed to the application- Throws:
Exception
- if any error occurs during the seeding process
-