[JAVA-32836] (#16267)
This commit is contained in:
parent
5360ae1a35
commit
dad6f36a97
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.jpa.query;
|
package com.baeldung.jpa.query.model;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -106,9 +106,7 @@ public class User {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder builder = new StringBuilder();
|
return "User [name=" + name + ", id=" + id + "]";
|
||||||
builder.append("User [name=").append(name).append(", id=").append(id).append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.jpa.query;
|
package com.baeldung.jpa.query.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -12,6 +12,8 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.baeldung.jpa.query.model.User;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<User, Integer>, UserRepositoryCustom {
|
public interface UserRepository extends JpaRepository<User, Integer>, UserRepositoryCustom {
|
||||||
@Query("SELECT u FROM User u WHERE u.status = 1")
|
@Query("SELECT u FROM User u WHERE u.status = 1")
|
|
@ -1,10 +1,12 @@
|
||||||
package com.baeldung.jpa.query;
|
package com.baeldung.jpa.query.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import com.baeldung.jpa.query.model.User;
|
||||||
|
|
||||||
public interface UserRepositoryCustom {
|
public interface UserRepositoryCustom {
|
||||||
|
|
||||||
List<User> findUserByEmails(Set<String> emails);
|
List<User> findUserByEmails(Set<String> emails);
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.jpa.query;
|
package com.baeldung.jpa.query.repository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.baeldung.jpa.query.model.User;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
|
@ -17,6 +17,9 @@ import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.JpaSort;
|
import org.springframework.data.jpa.domain.JpaSort;
|
||||||
import org.springframework.data.mapping.PropertyReferenceException;
|
import org.springframework.data.mapping.PropertyReferenceException;
|
||||||
|
|
||||||
|
import com.baeldung.jpa.query.model.User;
|
||||||
|
import com.baeldung.jpa.query.repository.UserRepository;
|
||||||
|
|
||||||
@DataJpaTest(properties = "spring.sql.init.data-locations=classpath:insert_users.sql", showSql = false)
|
@DataJpaTest(properties = "spring.sql.init.data-locations=classpath:insert_users.sql", showSql = false)
|
||||||
@AutoConfigurationPackage(basePackages = "com.baeldung.jpa.query")
|
@AutoConfigurationPackage(basePackages = "com.baeldung.jpa.query")
|
||||||
class UserQueryRepositoryIntegrationTest {
|
class UserQueryRepositoryIntegrationTest {
|
||||||
|
|
Loading…
Reference in New Issue