Database Reference
In-Depth Information
Spring Data repositories and entities
The objective of Spring Data is to provide an abstract layer of interfaces to developers and
hide all complexity of accessing data from the underlying data store. Spring Data repositor-
ies were introduced for the same cause and it exposes a generic interface
org.springframework.data.repository.Repository which is extended
and implemented by the domain-specific repositories.
Spring Data Neo4j was designed and developed to extend the same concept and provides a
generic repository interface
org.springframework.data.neo4j.repository.GraphRepository ,
which implements CRUDRepository , IndexRepository , SchemaIndexRepos-
itory , and TraversalRepository .
Developers can extend the generic repository interface and can define repositories specific
to their domain models, which can contain only domain-specific methods or operations and
all generic and common methods for performing CRUD operations or traversing or index-
ing will be injected/provided by the framework.
Let's extend our Spring Data Neo4j example that we created in the previous section and
create repositories for the search operation:
1. Create a new interface
org.neo4j.spring.samples.repositories.MovieRepository
that extends GraphRepository :
package org.neo4j.spring.samples.repositories;
import org.neo4j.spring.samples.domain.Movie;
import
org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface MovieRepository extends
GraphRepository<Movie>{
}
Search WWH ::




Custom Search