Spring Roo
  1. Spring Roo
  2. ROO-325

Roo artifacts are unaware of cyclic references (eg toString)

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0.0.RC2
    • Fix Version/s: None
    • Component/s: GENERAL OBJECTS
    • Labels:
      None

      Description

      Roo is currently not aware of cyclic references in the object graph of generated applications. This affects the toString addon as well as artifacts generated for Web scaffolding (list.jspx and show.jspx).

        Issue Links

          Activity

          Hide
          Ben Alex added a comment -

          Perhaps when building a toString() method (or equivalent) we should evaluate each accessor's return type and then query for BeanInfoMetadata. If the BeanInfoMetadata for the return type includes the return type we are generating the toString() for, query for EntityMetadata to determine if an accessor method is available (in which case the accessor method can be outputted for that type). If no EntityMetadata is available, just output whether the related object is null or non-null. This seems a relatively fail-safe approach to avoiding circular dependencies and still provides as much information as is reasonably possible to offer. Please feel free to discuss with me if you have any other ideas on how to tackle this. Other alternatives include maintaining a ThreadLocal with a Set of objects already outputted to detect a circular reference or using AspectJ pointcut to make a similar detection. I'm not a big fan of these given the memory consumption and performance impact, though.

          Show
          Ben Alex added a comment - Perhaps when building a toString() method (or equivalent) we should evaluate each accessor's return type and then query for BeanInfoMetadata. If the BeanInfoMetadata for the return type includes the return type we are generating the toString() for, query for EntityMetadata to determine if an accessor method is available (in which case the accessor method can be outputted for that type). If no EntityMetadata is available, just output whether the related object is null or non-null. This seems a relatively fail-safe approach to avoiding circular dependencies and still provides as much information as is reasonably possible to offer. Please feel free to discuss with me if you have any other ideas on how to tackle this. Other alternatives include maintaining a ThreadLocal with a Set of objects already outputted to detect a circular reference or using AspectJ pointcut to make a similar detection. I'm not a big fan of these given the memory consumption and performance impact, though.
          Hide
          Stefan Schmidt added a comment -

          Introduced simple detection for self references with commit 105e8c8972b904d619d040d85351487ea5481b7a.

          Show
          Stefan Schmidt added a comment - Introduced simple detection for self references with commit 105e8c8972b904d619d040d85351487ea5481b7a.
          Hide
          Angelo Genovese added a comment -

          Just wanted to note that this issue also affects the integration tests and Services.

          If a Service is added to a module other than the one containing the model entity a cyclic dependency is created between the two modules (Service -> entity/repository & test -> service).

          Show
          Angelo Genovese added a comment - Just wanted to note that this issue also affects the integration tests and Services. If a Service is added to a module other than the one containing the model entity a cyclic dependency is created between the two modules (Service -> entity/repository & test -> service).

            People

            • Assignee:
              Unassigned
              Reporter:
              Stefan Schmidt
            • Votes:
              11 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated: