Results 1 to 5 of 5

Thread: How to pass multiple entities to "service interface .." command

  1. #1
    Join Date
    Mar 2007
    Posts
    26

    Default How to pass multiple entities to "service interface .." command

    I am new to roo and I want to use services layer. I am creating service with following command, it accepts only one entity at a time, how can I configure multiple entities or all entities for the service through command line ?

    service --interface ~.TestService --entity ~.domain.Task

    I also want to configure for ~.domain.AppUser

    Thanks

  2. #2

    Default

    I have found that you can just edit the @RooService annotation directy e.g.

    @RooService(domainTypes = { Entity1.class, Entity2.class })

    and provided that you have the Roo shell running the code and aj files will be updated to support 2 entities in one service.

    What I am wondering is, you then end up with persistence methods for 2 entities that give all CRUD operation; but what do you do if say you don't want to support 'delete' for one of the entities ?

  3. #3
    Join Date
    Mar 2007
    Posts
    26

    Default

    Quote Originally Posted by PeteTh View Post
    I have found that you can just edit the @RooService annotation directy e.g.

    @RooService(domainTypes = { Entity1.class, Entity2.class })

    and provided that you have the Roo shell running the code and aj files will be updated to support 2 entities in one service.

    What I am wondering is, you then end up with persistence methods for 2 entities that give all CRUD operation; but what do you do if say you don't want to support 'delete' for one of the entities ?
    Thank you PeteTh for answering. Yes, I was thinking of doing it manually, but I feel once I edit any file manually, roo will stop that editing on its own. Is that right ? If not, I would do this manually. Right now, I am not worrying about disabling delete in service.

    is there any reason why roo does not allow giving one service access to more than one entity ?

    Thanks

  4. #4
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    You must not edit the AspectJ files (.aj) because Roo manages them, thus you would lose your changes if you modified them.

    The java files belong to you, so you can edit them and Roo will take care of changes whenever the shell is running. Of course, the java files have to compile, otherwise, Roo will have problems with them.

    I presume that Roo permits one Service per Entity because it makes sense: you wrap the CRUD for an Entity with a Service. So, unless you have some kind of hierarchy of objects, I don't know what you want to use as parameter of the persist methods (Besides, you prefer composition over inheritance in OOP)

    Greetings.

  5. #5
    Join Date
    Mar 2007
    Posts
    26

    Default

    Thank you very much for the answer.
    I have no idea why Roo says one entity per service is recommended approach. I can not imagine any service would need only one entity, for that purpose, we dont need service, just entity default and finder methods are enough. I mean, with this limitation service is not required as one can use entity in the controller itself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •