Created
September 4, 2014 12:52
-
-
Save sivaprasadreddy/d4e16e38b4b1fa7e62c3 to your computer and use it in GitHub Desktop.
HelloAngular DatabasePopulator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sivalabs.app; | |
import java.util.Arrays; | |
import java.util.Date; | |
import javax.annotation.PostConstruct; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Component; | |
import com.sivalabs.app.entities.Todo; | |
import com.sivalabs.app.repos.TodoRepository; | |
@Component | |
public class DatabasePopulator | |
{ | |
@Autowired | |
private TodoRepository todoRepository; | |
@PostConstruct | |
void init() | |
{ | |
try { | |
Todo t1 = new Todo(null, "Task 1", new Date()); | |
Todo t2 = new Todo(null, "Task 2", new Date()); | |
Todo t3 = new Todo(null, "Task 3", new Date()); | |
this.todoRepository.save(Arrays.asList(t1,t2,t3)); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment