mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-05-30 10:50:42 +00:00
2024-03 spring-11-jpql updated
This commit is contained in:
+2
-2
@@ -17,12 +17,12 @@ import java.util.Optional;
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final String STUDENT_NAME = "Вася";
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -18,12 +18,12 @@ import java.util.Optional;
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final String STUDENT_NAME = "Вася";
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -17,12 +17,12 @@ import java.util.Optional;
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final String STUDENT_NAME = "Вася";
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+1
-1
@@ -18,7 +18,7 @@ import java.util.Optional;
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
+3
-3
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -35,7 +35,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final String STUDENT_NAME = "Вася";
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final int EXPECTED_QUERIES_COUNT = 21;
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final int EXPECTED_QUERIES_COUNT = 11;
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -23,7 +23,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final int EXPECTED_QUERIES_COUNT = 2;
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -21,12 +21,12 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphTyp
|
||||
// Поэтому, для упрощения, пока вешаем над классом репозитория
|
||||
@Transactional
|
||||
@Repository
|
||||
public class OtusStudentRepositoryJpa implements OtusStudentRepository {
|
||||
public class JpaOtusStudentRepository implements OtusStudentRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public OtusStudentRepositoryJpa(EntityManager em) {
|
||||
public JpaOtusStudentRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DisplayName("Репозиторий на основе Jpa для работы со студентами ")
|
||||
@DataJpaTest
|
||||
@Import(OtusStudentRepositoryJpa.class)
|
||||
class OtusStudentRepositoryJpaTest {
|
||||
@Import(JpaOtusStudentRepository.class)
|
||||
class JpaOtusStudentRepositoryTest {
|
||||
|
||||
private static final int EXPECTED_NUMBER_OF_STUDENTS = 10;
|
||||
private static final long FIRST_STUDENT_ID = 1L;
|
||||
@@ -30,7 +30,7 @@ class OtusStudentRepositoryJpaTest {
|
||||
private static final int EXPECTED_QUERIES_COUNT = 3;
|
||||
|
||||
@Autowired
|
||||
private OtusStudentRepositoryJpa repositoryJpa;
|
||||
private JpaOtusStudentRepository repositoryJpa;
|
||||
|
||||
@Autowired
|
||||
private TestEntityManager em;
|
||||
+2
-2
@@ -6,12 +6,12 @@ import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryRepositoryJpa implements CategoryRepository {
|
||||
public class JpaCategoryRepository implements CategoryRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public CategoryRepositoryJpa(EntityManager em) {
|
||||
public JpaCategoryRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,12 +15,12 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public class EmployeeRepositoryJpa implements EmployeeRepository {
|
||||
public class JpaEmployeeRepository implements EmployeeRepository {
|
||||
|
||||
@PersistenceContext
|
||||
private final EntityManager em;
|
||||
|
||||
public EmployeeRepositoryJpa(EntityManager em) {
|
||||
public JpaEmployeeRepository(EntityManager em) {
|
||||
this.em = em;
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,12 +17,12 @@ import static org.springframework.util.StringUtils.hasLength;
|
||||
|
||||
@DisplayName("Репозиторий для Category должен")
|
||||
@DataJpaTest
|
||||
@Import(CategoryRepositoryJpa.class)
|
||||
@Import(JpaCategoryRepository.class)
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
class CategoryRepositoryJpaTest {
|
||||
class JpaCategoryRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private CategoryRepositoryJpa categoryRepository;
|
||||
private JpaCategoryRepository categoryRepository;
|
||||
|
||||
@DisplayName("возвращать список всех категорий")
|
||||
@Test
|
||||
+3
-3
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
@DisplayName("Репозиторий Employee должен")
|
||||
@DataJpaTest
|
||||
@Import(EmployeeRepositoryJpa.class)
|
||||
class EmployeeRepositoryJpaTest {
|
||||
@Import(JpaEmployeeRepository.class)
|
||||
class JpaEmployeeRepositoryTest {
|
||||
|
||||
private static final long FIRST_EMPLOYEE_ID = 1L;
|
||||
private static final long SECOND_EMPLOYEE_ID = 2L;
|
||||
@@ -51,7 +51,7 @@ class EmployeeRepositoryJpaTest {
|
||||
private TestEntityManager em;
|
||||
|
||||
@Autowired
|
||||
private EmployeeRepositoryJpa employeeRepository;
|
||||
private JpaEmployeeRepository employeeRepository;
|
||||
|
||||
|
||||
@DisplayName("возвращать список всех сотрудников")
|
||||
Reference in New Issue
Block a user