sql >> Database >  >> RDS >> Mysql

Java Spring JPA Paginering Werkt niet als er meer dan één pagina is

Na een tijdje zoeken vond ik het antwoord

Ik heb de telquery gemist. Na het toevoegen van de telquery werkte de paginering als een tierelier :)

@Repository
public interface SmsLogRepository extends JpaRepository<SmsLog, Long> {

@Query(value = "select * from sms_log s where s.phone_number = (:ph) \n#pageable\n", countQuery = "select count(*) from sms_log s where s.phone_number = (:ph) \n#pageable\n", nativeQuery = true)
Page<SmsLog> findByPhoneNumber(@Param("ph") String phoneNumber, Pageable pageable);

@Query(value = "select * from sms_log s where s.phone_number = (:ph) AND s.message_timestamp between (:fromdate) and (:todate) \n#pageable\n",countQuery = "select count(*) from sms_log s where s.phone_number = (:ph) AND s.message_timestamp between (:fromdate) and (:todate) \n#pageable\n", nativeQuery = true)
Page<SmsLog> findByPhoneNumberAndDate(@Param("ph") String phoneNumber, @Param("fromdate") String fromDate, @Param("todate") String todate, Pageable pageable);

@Query(value = "select * from sms_log s where s.message_timestamp between (:fromdate) and (:todate) \n#pageable\n",countQuery = "select count(*) from sms_log s where s.message_timestamp between (:fromdate) and (:todate) \n#pageable\n", nativeQuery = true)
Page<SmsLog> findByDate(@Param("fromdate") String fromDate, @Param("todate") String todate, Pageable pageable);
}



  1. MySQL combineert twee kolommen in één kolom

  2. Query in SQL-stijl gebruiken in Excel met VBA

  3. Wat is de beste manier om te ontsnappen aan niet-opgemaakte tekens in to_char van Oracle?

  4. Python:ModuleNotFoundError:Geen modulenaam 'mysql'