sdr-mixins
The Spring Data Repository "mixins" project provides users with a way to make more granular repositories to use with Spring Data. Normally a user could implement the CrudRepository
. However, this approach exposes methods like deleteAll()
to the rest of the application.
With the various interfaces users can control which methods are exposed by their repository interface, thus insuring that methods that should not be invoked are never available to be called in the first place.
NOTE: In the end this really is just a preference for me that I really like. I made this available on the off chance that others like it as well. I've personally found spring-data
and all of its accompanying modules to be fantastic libraries that help me be very productive.
Installation
To use add the following dependency to your pom
<dependency>
<groupId>com.sdoctech</groupId>
<artifactId>sdr-mixins</artifactId>
<version>1.0</version>
</dependency>
Usage
Suppose that you only want to expose the ability to find an entity by its id and to test for existence of an entity by its id. You would just do the following:
public interface MyNewRepository<MyEntity, Long> extends
HasFindById<MyEntity, Long>,
HasExistsById<MyEntity, Long>,
Repository<MyEntity, Long> {
}