Search code examples
springspring-roo

spring roo generate repositories for all entities


I am using spring roo 1.2.5 with oracle database

My goal is to create the entities, repositories and service classes in seperate packages

I was able to generate all the entities using the single command :

database reverse engineer --schema schema_name --activeRecord false --disableGeneratedIdentifiers true --disableVersionFields true --package ~domain

but when I want to generate the repositories, I am forced to proceed one by one using the command :

repository jpa --interface MyInterface --entity MyEntity

Is there a way to generate all repositories in one command in the same way as the entities?


Solution

  • Repositories

    I don't believe there is an all option for generating repository jpa. You could generate a Roo script with an external tool. Scan for all entities (e.g. list files in your domain package) and generate a line for each entity

    repository jpa --interface ~.repo.${ENTITY}Repository --entity ~.domain.${ENTITY}

    replacing ${ENTITY} with actual entity class name. Save the generated script as a file. Then run this script with

    script --file ...

    Services

    For service interfaces and classes use

    service all