Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-2716

roo json mappings are missing set/reference relationship methods


    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.1.5.RELEASE, 1.2.0.M1
    • Fix Version/s: None
    • Component/s: WEB MVC
    • Environment:
      OSX Lion, but that is irrelevant for this issue, the same behavior is present on Linux, etc.


      When a pair of tables have a parent/child relationship, the REST conventions dictate that a list of child elements belonging to a parent should be exposed as a rest method.

      If one has:

      /api/parent - list of parents

      {parentId} - specific parent
      /api/children - list of all children regardless of parent
      /api/children/{childId} - specific child

      Where there is a set/reference ONE_TO_MANY bidirectional relationship between parent and child, one should also generate


      /children - list of children belonging to parentId

      as an exposed REST method that returns the list of children belonging to a parent.

      Currently roo does not do this. At least. This appears to be the one missing element in the JSON API generation.

      Here's my test case:

      project com.test.foo
      dependency add --groupId org.codehaus.jackson --artifactId jackson-jaxrs --version 1.8.4
      jpa setup --provider HIBERNATE --database POSTGRES --databaseName cm --hostName localhost --userName admin --password fooo2 --transactionManager

      entity --class ~.domain.Parent --testAutomatically
      field string --fieldName name
      entity --class ~.domain.Child --testAutomatically
      field string --fieldName name

      // Setup heirarchical references
      focus --class ~.domain.Parent
      field set --fieldName children --type ~.domain.Child --cardinality ONE_TO_MANY --mappedBy parent
      focus --class ~.domain.Child
      field reference --fieldName parent --type ~.domain.Parent --cardinality MANY_TO_ONE

      json all --deepSerialize
      web mvc json setup
      web mvc json all
      perform eclipse




            • Assignee:
              bedge Bruce Edge
            • Votes:
              5 Vote for this issue
              7 Start watching this issue


              • Created: