Announcement Announcement Module
No announcement yet.
(MVC) Views and lists Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • (MVC) Views and lists

    I have A with a @OneToMany to B (and B with a @ManyToOne back to A).

    But when I view A's:
    * show.jspx, I see no references to B whatsoever: see other, ad hoc thread and Jira ticket.
    * update.jspx, I only see the message "This relationship is managed from the <B> side." instead of a list of my Bs.
    Is this the current implementation, or is there something wrong with my design (for example the cardinalities).

  • #2
    To create a bi-directional relationship from a JPA perspective you also need to make sure to include the mappedBy attribute. Otherwise Roo would scaffold your forms in a way that the relationship is managed from the many side. There is an example at the end of this chapter in our docs:

    Also, the clinic.roo script illustrates this style of relationship as well.


    • #3

      I am aware of the mappedBy attribute, and use it.

      In the project that I attached to
      take for example:
      *** "Project" for A, and
      *** "RiskIndex" for B.


      • #4
        While writing unit tests for some manual methods, I realize another possible issue.

        Using the MVC UI, I associate Projects and RiskIndexes on the RiskIndex UI, given that it manages the relationship.

        If I do the same via API, i.e.:
        then look at project.getRiskIndexes(), it is empty. Which is understandable given the "simple" setters currently generated.

        But given the bi-directional relationship, should the setter be generated as follows:
        public void RiskIndex.setProject(Project project) {
        this.project = project;

        Yes we can override / push-in the setters manually, but if they can be generated the right way automatically...


        • #5
          Well, my latest "issue" may be that:
          * In my unit tests I am not persisting anything, and
          * The correct management of bi-directional relationships relies on the FKs and JPA...

          Because when I reproduce my unit tests on the MVC UI I get the expected results, even though I (can) only build collections via the "many" side.

          The lists are still not displayed correctly however, so my initial issue remains...