Skip to content

Instantly share code, notes, and snippets.

@finsterthecat
Last active January 7, 2018 17:22
Show Gist options
  • Save finsterthecat/0d1f3af46e3c2a1c295941ff6f8939dc to your computer and use it in GitHub Desktop.
Save finsterthecat/0d1f3af46e3c2a1c295941ff6f8939dc to your computer and use it in GitHub Desktop.
package io.navan.heroesbackend;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
public interface HeroRepository extends CrudRepository<Hero, Long> {
@RestResource(path = "name", rel="name")
@Query("from Hero h where lower(h.name) like CONCAT('%', lower(:contains), '%')")
public Iterable<Hero> findByName(@Param("contains") String name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment