[JAVA-32833] (#16265)
* [JAVA-32833] * [JAVA-32833] Fixed configuration
This commit is contained in:
parent
b5bfa4697d
commit
c3939b1850
|
@ -32,7 +32,7 @@ public class PersistenceConfig {
|
|||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
em.setDataSource(dataSource());
|
||||
em.setPackagesToScan("com.baeldung.jpa.simple.entity");
|
||||
em.setPackagesToScan("com.baeldung.jpa.simple.model");
|
||||
|
||||
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
em.setJpaVendorAdapter(vendorAdapter);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jpa.simple.entity;
|
||||
package com.baeldung.jpa.simple.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jpa.simple.entity;
|
||||
package com.baeldung.jpa.simple.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.jpa.simple.entity;
|
||||
package com.baeldung.jpa.simple.model;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import org.springframework.data.repository.ListCrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Book;
|
||||
import com.baeldung.jpa.simple.model.Book;
|
||||
|
||||
@Repository
|
||||
public interface BookListRepository extends ListCrudRepository<Book, Long> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.data.repository.ListCrudRepository;
|
|||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Book;
|
||||
import com.baeldung.jpa.simple.model.Book;
|
||||
|
||||
@Repository
|
||||
public interface BookPagingAndSortingRepository extends PagingAndSortingRepository<Book, Long>, ListCrudRepository<Book, Long> {
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Foo;
|
||||
import com.baeldung.jpa.simple.model.Foo;
|
||||
|
||||
public interface IFooDAO extends JpaRepository<Foo, Long> {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.User;
|
||||
import com.baeldung.jpa.simple.model.User;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Integer>, UserRepositoryCustom {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.User;
|
||||
import com.baeldung.jpa.simple.model.User;
|
||||
|
||||
public interface UserRepositoryCustom {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.User;
|
||||
import com.baeldung.jpa.simple.model.User;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.baeldung.jpa.simple.service;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Foo;
|
||||
import com.baeldung.jpa.simple.model.Foo;
|
||||
import com.baeldung.jpa.simple.repository.IFooDAO;
|
||||
|
||||
@Service
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.baeldung.jpa.simple.service;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Foo;
|
||||
import com.baeldung.jpa.simple.model.Foo;
|
||||
|
||||
public interface IFooService {
|
||||
Foo create(Foo foo);
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package com.baeldung.jpa.simple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Book;
|
||||
import com.baeldung.jpa.simple.model.Book;
|
||||
import com.baeldung.jpa.simple.repository.BookListRepository;
|
||||
|
||||
@SpringBootTest(classes = JpaApplication.class)
|
||||
|
@ -25,6 +26,6 @@ class BookListRepositoryIntegrationTest {
|
|||
bookListRepository.saveAll(Arrays.asList(book1, book2, book3));
|
||||
|
||||
List<Book> books = bookListRepository.findBooksByAuthor("John Doe");
|
||||
Assertions.assertEquals(3, books.size());
|
||||
assertEquals(3, books.size());
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package com.baeldung.jpa.simple;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -11,7 +13,7 @@ import org.springframework.data.domain.PageRequest;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Book;
|
||||
import com.baeldung.jpa.simple.model.Book;
|
||||
import com.baeldung.jpa.simple.repository.BookPagingAndSortingRepository;
|
||||
|
||||
@SpringBootTest
|
||||
|
@ -29,8 +31,8 @@ class BookPagingAndSortingRepositoryIntegrationTest {
|
|||
|
||||
Pageable pageable = PageRequest.of(0, 2, Sort.by("title").descending());
|
||||
List<Book> books = bookPagingAndSortingRepository.findBooksByAuthor("John Miller", pageable);
|
||||
Assertions.assertEquals(2, books.size());
|
||||
Assertions.assertEquals(book3.getId(), books.get(0).getId());
|
||||
Assertions.assertEquals(book2.getId(), books.get(1).getId());
|
||||
assertEquals(2, books.size());
|
||||
assertEquals(book3.getId(), books.get(0).getId());
|
||||
assertEquals(book2.getId(), books.get(1).getId());
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.springframework.test.annotation.DirtiesContext;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.Foo;
|
||||
import com.baeldung.jpa.simple.model.Foo;
|
||||
import com.baeldung.jpa.simple.service.IFooService;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import com.baeldung.jpa.simple.entity.User;
|
||||
import com.baeldung.jpa.simple.model.User;
|
||||
import com.baeldung.jpa.simple.repository.UserRepository;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
|
|
Loading…
Reference in New Issue