Skip to content

Commit 95cc331

Browse files
committed
Part 15: Add CompanyRepository.java
1 parent 44ca9a2 commit 95cc331

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package spring.oldboy.database.repository.company_repository;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.data.jpa.repository.Query;
5+
import org.springframework.data.repository.query.Param;
6+
import spring.oldboy.database.entity.Company;
7+
8+
import java.util.List;
9+
import java.util.Optional;
10+
11+
public interface CompanyRepository extends JpaRepository<Company, Integer> {
12+
13+
@Query("select c from Company c " +
14+
"join fetch c.locales cl " +
15+
"where c.name = :name2")
16+
Optional<Company> findByName(@Param("name2") String name);
17+
18+
List<Company> findAllByNameContainingIgnoreCase(String fragment);
19+
}

0 commit comments

Comments
 (0)