Revize abaa5f46
Přidáno uživatelem Jakub Šmíd před asi 2 roky(ů)
- ID abaa5f461242c640ae1e7daaddb6bfc1b1419db9
- Rodič c1df89f5
backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemRepository.java | ||
---|---|---|
3 | 3 |
import org.springframework.data.jpa.repository.JpaRepository; |
4 | 4 |
import org.springframework.data.jpa.repository.Query; |
5 | 5 |
import org.springframework.stereotype.Repository; |
6 |
import org.springframework.transaction.annotation.Transactional; |
|
6 | 7 |
|
7 |
import java.util.Set;
|
|
8 |
import java.util.List;
|
|
8 | 9 |
import java.util.UUID; |
9 | 10 |
|
10 | 11 |
/** |
11 | 12 |
* Catalog repository |
12 | 13 |
*/ |
13 |
@Repository |
|
14 |
@Repository()
|
|
14 | 15 |
public interface CatalogItemRepository extends JpaRepository<CatalogItem, UUID> { |
15 | 16 |
|
16 | 17 |
/** |
... | ... | |
22 | 23 |
* @return set of catalog items satisfying filter conditions |
23 | 24 |
*/ |
24 | 25 |
@Query("SELECT DISTINCT e FROM CatalogItem e " + |
25 |
"LEFT JOIN FETCH AlternativeName a ON e = a.catalogItem " +
|
|
26 |
"LEFT JOIN FETCH Country c ON e = c.catalogItem " +
|
|
27 |
"INNER JOIN FETCH e.types t " +
|
|
26 |
"LEFT JOIN e.alternativeNames a " +
|
|
27 |
"LEFT JOIN e.countries c " +
|
|
28 |
"LEFT JOIN e.types t " +
|
|
28 | 29 |
"WHERE (?1 = '' OR UPPER(e.name) LIKE UPPER(?1) OR UPPER(a.name) LIKE UPPER(?1)) " + |
29 | 30 |
"AND (?2 = '' OR UPPER(c.name) LIKE UPPER(?2)) " + |
30 | 31 |
"AND (?3 = '' OR UPPER(t.type) LIKE UPPER(?3))") |
31 |
Set<CatalogItem> filterCatalog(String name, String country, String type); |
|
32 |
@Transactional(readOnly = true) |
|
33 |
List<CatalogItem> filterCatalog(String name, String country, String type); |
|
34 |
|
|
35 |
@Query("SELECT DISTINCT e FROM CatalogItem e " + |
|
36 |
"LEFT JOIN e.alternativeNames a " + |
|
37 |
"LEFT JOIN e.countries c " + |
|
38 |
"WHERE (?1 = '' OR UPPER(e.name) LIKE UPPER(?1) OR UPPER(a.name) LIKE UPPER(?1)) " + |
|
39 |
"AND (?2 = '' OR UPPER(c.name) LIKE UPPER(?2))") |
|
40 |
List<CatalogItem> filterCatalog2(String name, String country); |
|
32 | 41 |
} |
Také k dispozici: Unified diff
Experiment with database