Align JPA sample with Hibernate 5.1’s table naming
The name of the table for a many-to-many relationship has changed in Hibernate 5.1. This commit updates the JPA sample’s import.sql accordingly. It also updates the repository integration tests to verify that the data has been imported successfully. Closes gh-5880
This commit is contained in:
@@ -24,6 +24,7 @@ import sample.jpa.domain.Note;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -34,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Transactional
|
||||
public class JpaNoteRepositoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -43,6 +45,9 @@ public class JpaNoteRepositoryIntegrationTests {
|
||||
public void findsAllNotes() {
|
||||
List<Note> notes = this.repository.findAll();
|
||||
assertThat(notes).hasSize(4);
|
||||
for (Note note : notes) {
|
||||
assertThat(note.getTags().size()).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import sample.jpa.domain.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -34,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Transactional
|
||||
public class JpaTagRepositoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -43,6 +45,9 @@ public class JpaTagRepositoryIntegrationTests {
|
||||
public void findsAllTags() {
|
||||
List<Tag> tags = this.repository.findAll();
|
||||
assertThat(tags).hasSize(3);
|
||||
for (Tag tag : tags) {
|
||||
assertThat(tag.getNotes().size()).isGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user