Search in sources :

Example 1 with Note

use of sample.jpa.domain.Note in project spring-boot by spring-projects.

the class IndexController method index.

@GetMapping("/")
@Transactional(readOnly = true)
public ModelAndView index() {
    List<Note> notes = this.noteRepository.findAll();
    ModelAndView modelAndView = new ModelAndView("index");
    modelAndView.addObject("notes", notes);
    return modelAndView;
}
Also used : Note(sample.jpa.domain.Note) ModelAndView(org.springframework.web.servlet.ModelAndView) GetMapping(org.springframework.web.bind.annotation.GetMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Note

use of sample.jpa.domain.Note in project spring-boot by spring-projects.

the class JpaNoteRepositoryIntegrationTests method findsAllNotes.

@Test
public void findsAllNotes() {
    List<Note> notes = this.repository.findAll();
    assertThat(notes).hasSize(4);
    for (Note note : notes) {
        assertThat(note.getTags().size()).isGreaterThan(0);
    }
}
Also used : Note(sample.jpa.domain.Note) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

Note (sample.jpa.domain.Note)2 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Transactional (org.springframework.transaction.annotation.Transactional)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1