Results 1 to 2 of 2

Thread: constructors in persistent classes

  1. #1
    Join Date
    Mar 2007
    Posts
    113

    Default constructors in persistent classes

    hi...

    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 ??

    thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    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.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Posting Permissions

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