Databases Reference
In-Depth Information
Next, we must create an interface for our entity specific repository. We can do this
by extending the BaseRepository interface and providing the type of our entity and
the type of its ID as type parameters. The source code of the ContactRepository
interface is given as follows:
public interface ContactRepository extends BaseRepository<Contact,
Long> {
//Declare custom methods here.
}
Next, we must create the entity specific concrete repository. We can create a concrete
repository by following these steps:
1.
Annotate the concrete repository class with @Repository annotation that
identifies the created class as a repository class.
2.
Extend the BaseRepositoryImpl class and give the type of the entity and the
type of the entity's ID as a type parameter.
3.
Implement the ContactRepository interface.
The source code of the ContactRepositoryImpl class is as follows:
@Repository
public class ContactRepositoryImpl extends BaseRepositoryImpl<Contact,
Long> implements ContactRepository {
//Add custom query methods here
}
Congratulations! We have now created a single concrete repository in the old
fashioned way. The structure of our repository implementation is illustrated in the
following figure:
 
Search WWH ::




Custom Search