Announcement Announcement Module
Collapse
No announcement yet.
Does Data Rest support Spring Data's expression operators, eg. Between, GreaterThan? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does Data Rest support Spring Data's expression operators, eg. Between, GreaterThan?

    Hi all, I am very new to spring data rest.

    I know Spring Data Common supports queries(methods in the repository) with operators such as Between, LessThan, GreaterThan, Like for the property expressions.

    I am wondering if these operators are also supported in Data Rest? If supported, what do the Rest API URLs look like when these operators are used. For example, if I need to query people whose age is between 20 and 30. Query in repository should be List<Person> findByAgeBetween(Long min, Long max); But what is the URL?


  • #2
    Yes, it is supported, you can do:

    Code:
    @RestResource
    interface PersonRepository extends JpaRepository<Person, Integer> {
    List<Person> findByAgeBetween(@Param("min") Long min, @Param("max") Long max); 
    }
    And the Url to get that data is: "<some-url>/persons/search/findByAgeBetween?min=18&max=10

    Comment

    Working...
    X