[ROO-3712] Generate repositories for readOnly and readAndWrite entities Created: 17/Feb/16  Updated: 22/Feb/16  Resolved: 22/Feb/16

Status: Resolved
Project: Spring Roo
Component/s: None
Affects Version/s: 2.0.0.M1
Fix Version/s: 2.0.0.M2

Type: New Feature Priority: Minor
Reporter: Juan Carlos García del Canto Assignee: Juan Carlos García del Canto
Resolution: Complete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

When developer tries to generate new repository using repository commands, he needs to define for which entity wants to generate the repository.

Take in mind that this entity could be "readOnly" or "readAndWrite":

  • ReadOnly entities:
    • Roo generates an interface EntityCustomRepository to include dynamic queries.
    • Roo creates an empty implementation of previous interface that extends of QueryDslRepositorySupport.
    • Roo generates an interface called ReadOnlyRepository that extends Repository like the following:
      @NoRepositoryBean
      @Transactional(readOnly = true)
      public interface ReadOnlyRepository<T, ID extends Serializable>
          extends Repository<T, ID> {
      
        T findOne(ID id);
      
        boolean exists(ID id);
      
        List<T> findAll();
      
        List<T> findAll(Iterable<ID> ids);
      
        long count();
      
        List<T> findAll(Sort sort);
      
        Page<T> findAll(Pageable pageable);
      
        T getOne(ID id);
      }
      
    • Roo creates an interface that extends interface EntityCustomRepository and ReadOnlyRepository. Will be annotated with @RooRepository
  • "ReadAndWrite" entities:
    • Roo generates an interface EntityCustomRepository to include dynamic queries.
    • Roo creates an empty implementation of previous interface that extends of QueryDslRepositorySupport.
    • Roo generates an interface that extends EntityCustomRepository and JpaRepository. Will be annotated with @RooRepository.


 Comments   
Comment by Juan Carlos García del Canto [ 19/Feb/16 ]

Generating Spring Data repositories taking in mind if entity is defined as readOnly or not.

By default, Spring Roo generates a RepositoryCustom interface and its implementation that extends QueryDslRepositorySupport.

All extends, implements, constructors, etc.. are included on ITDs to be able to update them automatically if referenced entity changes.

These changes have been applied on the following commits:

https://github.com/spring-projects/spring-roo/commit/fb1ce6fd90162ddf0baed0dc5a544bfaec1684fb
https://github.com/spring-projects/spring-roo/commit/8c3a9f50acde532e7d7c326d5ab765e32ccf19fd
https://github.com/spring-projects/spring-roo/commit/e854d367e2e8778ac43bb445aa676eda82cd2204
https://github.com/spring-projects/spring-roo/commit/471111747a128459cf717638963a9493dd018b83

We are going to add @Transactional(readOnly=true) annotation on all generated repositories.

Comment by Juan Carlos García del Canto [ 22/Feb/16 ]

Including @Transactional(readOnly = true) for every generated Repository.

You could check applied changes on the following commit:

https://github.com/spring-projects/spring-roo/commit/7714ae68cf8eb6116355beab98428ff27f5f93fa

Generated at Sun Dec 08 05:24:04 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.