-
Couldn't load subscription status.
- Fork 699
Developer guide
The Spring Data Commons module provides a sophisticated system to gather and use entity mapping and conversion functionality. The core model abstractions are PersistentEntity, PersistentProperty. These abstractions can be created and used through a MappingContext. In top of that we provide an EntityConverter abstraction consisting of EntityReader and EntityWriter.
TODO
As an important part of the entity conversion on the reading side is creating instances of the domain class an EntityInstantiator API allows plugging custom code for
We provide a set of repository interfaces that either declare a user's repository interface as a Spring Data interface or even pull in functionality that can be implemented generically.
-
Repository- A plain marker interface to let the Spring Data infrastructure pick up user defined repositories. -
CrudRepository- ExtendsRepositoryand adds basic persistence methods like saving entities, finding entities and deleting them. -
PagingAndSortingRepositories- ExtendsCrudRepositoryand adds method for access ing entities page by page and sorted by a given criteria.
TODO
When building a store implementation for a data store we do not already support the most interesting parts are the mapping and conversion system as well as the repository abstraction. If the store you target already supports entity mapping (like JPA for example) you can implement the repository abstraction directly on top of it. Otherwise you need to integrate with the mapping and conversion system. The following sections will describe the important abstractions and classes you'll have to take a look and and extend/implement.
As example for an implementation of store support with Spring Data mapping have a look at Spring Data MongoDB, for a plain repository abstraction integration consider taking a look at Spring Data JPA.
TODO
The very core of the repository abstraction is the factory to create repository instances. RepositoryFactorySupport requires the following methods to be implemented:
-
getEntityInformation(…)- return theEntityInformationwhich encapsulates ways to determine whether an entity is new, lookup the identifier of the entity as well as the type of the id.AbstractEntityInformationis the class you'll probably want to extend. -
getRepositoryBaseClass(…)- returns the type of the backing instance of the repositories which usually implements CRUD methods etc. Needed to inspect the user's repository interface for query methods before actually creating the instance. -
getTargetRepository(…)- returns an instance of the type returned bygetRepositoryBaseClass(…). This instance will usually return one of the Spring Data Repository interfaces.
TODO
TODO