May 24th, 2009, 08:01 PM
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 ??
May 24th, 2009, 08:18 PM
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.