| /* |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package org.apache.ignite.springdata22.examples; |
| |
| import java.util.List; |
| import javax.cache.Cache; |
| import org.apache.ignite.springdata22.examples.model.Person; |
| import org.apache.ignite.springdata22.repository.IgniteRepository; |
| import org.apache.ignite.springdata22.repository.config.Query; |
| import org.apache.ignite.springdata22.repository.config.RepositoryConfig; |
| import org.springframework.data.domain.Pageable; |
| |
| /** |
| * Apache Ignite Spring Data repository backed by Ignite Person's cache. |
| * </p> |
| * To link the repository with an Ignite cache use {@link RepositoryConfig#cacheName()} annotation's parameter. |
| */ |
| @RepositoryConfig(cacheName = "PersonCache") |
| public interface PersonRepository extends IgniteRepository<Person, Long> { |
| /** |
| * Gets all the persons with the given name. |
| * @param name Person name. |
| * @return A list of Persons with the given first name. |
| */ |
| public List<Person> findByFirstName(String name); |
| |
| /** |
| * Returns top Person with the specified surname. |
| * @param name Person surname. |
| * @return Person that satisfy the query. |
| */ |
| public Cache.Entry<Long, Person> findTopByLastNameLike(String name); |
| |
| /** |
| * Getting ids of all the Person satisfying the custom query from {@link Query} annotation. |
| * |
| * @param orgId Query parameter. |
| * @param pageable Pageable interface. |
| * @return A list of Persons' ids. |
| */ |
| @Query("SELECT id FROM Person WHERE orgId > ?") |
| public List<Long> selectId(long orgId, Pageable pageable); |
| } |
| |