Announcement Announcement Module
No announcement yet.
constructors in persistent classes Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • constructors in persistent classes


    i tried to test whether ROO can add a sporadic functionality to a project (use it when needed). so, i have an existing project and I used ROO to generate one of the entities (Address). When using ROO, there was no empty constructor generated in the persistent class. What's the philosophy of ROO and constructor ??


  • #2
    The entity constructor creation logic can be found in Roo's EntityMetadata.getNoArgConstructor() method. Essentially Roo will only create a no-arg constructor on a @RooEntity if you have defined your own constructor in the target .java class and that constructor is not a no-arg constructor.

    If you define no constructor in the @RooEntity Java class at all, no constructor needs to be generated by Roo as the Java default no-arg constructor will apply.

    If you define a no-arg constructor in the @RooEntity Java class, no constructor needs to be generated by Roo as you have provided one yourself by hand.

    Hope this clarifies the semantics and rationale. If you have any questions/concerns/issues, please don't hesitate to let me know.