mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-06-20 11:14:34 +00:00
2021-03 spring-13-data-jpa updated
This commit is contained in:
+14
-1
@@ -3,6 +3,8 @@ package ru.otus.springdata;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import ru.otus.springdata.domain.Email;
|
||||
import ru.otus.springdata.domain.Person;
|
||||
import ru.otus.springdata.repository.EmailRepository;
|
||||
@@ -23,7 +25,8 @@ public class Main {
|
||||
emailL = emailRepository.save(emailL);
|
||||
|
||||
Person pushkin = personRepository.save(new Person("Pushkin", emailP));
|
||||
Person lermontov = personRepository.save(new Person("Lermontov",emailL));
|
||||
Person lermontov = personRepository.save(new Person("Lermontov", emailL));
|
||||
|
||||
|
||||
System.out.println("\n\nИщем всех пёрсонов");
|
||||
System.out.println(personRepository.findAll());
|
||||
@@ -48,6 +51,16 @@ public class Main {
|
||||
emailRepository.updateEmailById(emailL.getId(), "michail1984@lermontov.ru");
|
||||
emailRepository.findById(emailL.getId()).ifPresent(e -> System.out.println("После обновления: " + e));
|
||||
|
||||
|
||||
System.out.println("\n\nИщем все почты по вхождению \".ru\"");
|
||||
ExampleMatcher ignoringExampleMatcher = ExampleMatcher.matchingAny()
|
||||
.withMatcher("address", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase())
|
||||
.withIgnorePaths("id");
|
||||
|
||||
Example<Email> example = Example.of(new Email(1, ".ru"), ignoringExampleMatcher);
|
||||
|
||||
System.out.println(emailRepository.findAll(example));
|
||||
|
||||
System.out.println("\n\n");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user