Update native query in AdviceRepo
package greencity.repository;
import greencity.entity.Advice;
+import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
@@ -16,7 +18,8 @@ public interface AdviceRepo extends JpaRepository<Advice, Long> {
* @return Advice Object in Optional
* @author Vitaliy Dzen
*/
- @Query(nativeQuery = true, value = "SELECT * FROM advices WHERE habit_dictionary_id = ?1 ORDER BY RAND() LIMIT 1;")
+ @Query(nativeQuery = true, value = "SELECT * FROM advices WHERE habit_dictionary_id = ?1 "
+ + "ORDER BY RANDOM() LIMIT 1;")
Optional<Advice> getRandomAdviceByHabitId(Long habitId);
/**
