spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
915 stars 560 forks source link

Improvment suggestion: Better support for read only repositories #79

Open bjconlan opened 11 years ago

bjconlan commented 11 years ago

Although it is possible to disable the CUD parts of the CRUDRepsoitory by adding @exported(false) to overloaded methods of the CRUDRepository i think it would be nicer to see either:

The Introduction to a read only repository in the spring-data-commons ie:

@NoRepositoryBean
public interface ReadOnlyRepository<T, ID extends Serializable> extends Repository<T, ID> {
    T findOne(ID id);
    List<T> findAll();
    List<T> findAll(Sort sort);
    Page<T> findAll(Pageable pageable);
}

Which can be used as the decoration point when using spring-data-rest-webmvc instead of CRUDRepository (although I imagine a CRUDRepository would inherit from such a class)

or

Have the spring-data-rest-webmvc decorate any Repository based interface and follow some sort of expected method signatures for providing the appropriate Get/Put/Post/Patch/Delete REST operations.

jbrisbin commented 11 years ago

We currently support only CrudRepository because that's what the Repositories implementation in spring-data-commons supports. [1]

Once we can handle all repository types in that class, then Spring Data REST can begin to support non-CrudRepository repositories.

/cc @olivergierke

[1] - https://github.com/SpringSource/spring-data-commons/blob/master/src/main/java/org/springframework/data/repository/support/Repositories.java#L75