-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MatheusCandido
committed
Sep 15, 2020
1 parent
0efdc49
commit 1727d55
Showing
5 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
Backend/src/main/java/com/dspesquisa/repositories/RecordRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
package com.dspesquisa.repositories; | ||
|
||
import com.dspesquisa.entities.Genre; | ||
|
||
import com.dspesquisa.entities.Record; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.Instant; | ||
|
||
@Repository | ||
public interface RecordRepository extends JpaRepository<Record, Long> { | ||
|
||
@Query(value = "SELECT obj FROM Record obj WHERE " + | ||
"(coalesce(:min, null) IS NULL OR obj.moment >= :min) AND " + | ||
"(coalesce(:max, null) IS NULL OR obj.moment <= :max)") | ||
|
||
Page<Record> findByMoments(Instant min, Instant max, Pageable pageRequest); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
spring.profiles.active=test | ||
|
||
spring.jpa.open-in-view=false | ||
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS = false |