-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseLoader.java
More file actions
30 lines (23 loc) · 1.13 KB
/
DatabaseLoader.java
File metadata and controls
30 lines (23 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package edu.psu.matchwarketplace.bootstrap;
import edu.psu.matchwarketplace.model.Watch;
import edu.psu.matchwarketplace.repository.WatchRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
@Component
public class DatabaseLoader implements ApplicationListener<ContextRefreshedEvent> {
//
// get the repository
@Autowired
private WatchRepository watchRepository;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
System.out.println("*** this is called when we start the application");
// make the ID be autogenerated
// watchRepository.addWatch(new Watch(1L, "Rolex", "Daytona", 24000.00));
// watchRepository.addWatch(new Watch(2L, "Blancpain", "Fifty Fathoms", 15000.00));
watchRepository.addWatch(new Watch(null, "Rolex", "Daytona", 24000.00));
watchRepository.addWatch(new Watch(null, "Blancpain", "Fifty Fathoms", 15000.00));
}
}