parent
6ba1eb7fea
commit
38455389f7
3 changed files with 39 additions and 1 deletions
@ -1,10 +1,30 @@ |
|||||||
package com.mousetech.gourmetj; |
package com.mousetech.gourmetj; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository; |
import org.springframework.data.jpa.repository.JpaRepository; |
||||||
|
import org.springframework.data.jpa.repository.Query; |
||||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
import com.mousetech.gourmetj.persistence.model.Category; |
import com.mousetech.gourmetj.persistence.model.Category; |
||||||
|
|
||||||
|
/** |
||||||
|
* JpaRepositort for Categories, which relate ManyToOne to Recipe. |
||||||
|
* Service method is @see CategoryService |
||||||
|
* |
||||||
|
* @author timh |
||||||
|
* @since Dec 28, 2021 |
||||||
|
*/ |
||||||
|
|
||||||
@Repository |
@Repository |
||||||
public interface CategoryRepository extends JpaRepository<Category, Long> { |
public interface CategoryRepository |
||||||
|
extends JpaRepository<Category, Long> { |
||||||
|
|
||||||
|
final static String SQL_FIND_CATEGORIES = |
||||||
|
"SELECT DISTINCT category from categories" |
||||||
|
+ " where category is not null and category <> ''" |
||||||
|
+ " ORDER BY category ASC"; |
||||||
|
|
||||||
|
@Query(value = SQL_FIND_CATEGORIES, nativeQuery = true) |
||||||
|
public List<String> findDistinctCategoryNative(); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue