Spring Roo
  1. Spring Roo
  2. ROO-2211

Owned OneToMany/ManyToOne relations with GAE is broken

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 1.1.2.RELEASE
    • Fix Version/s: 1.1.3.RELEASE
    • Component/s: GAE
    • Labels:
      None

      Description

      When an entity field is flagged as a OneToMany/ManyToOne relation, the Roo generated code *_Roo_GAE.aj indiscriminately tags the .id with @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true"). This can be problematic because the default entity id type is Long and it cannot be assigned the "gae.encoded-pk" extension:

      "...A field with the "gae.encoded-pk" extension can only be applied to a String primary key..."

      The _Roo_GAE code should be adjusted to make sure the .id field is a String.

      A second problem related to the same issue is that when you manually define the entity's .id as a String, this breaks the *_Roo_JavaBean.aj code that expects Long id's to set/get the related HashSets...

        Issue Links

          Activity

          Hide
          James Tyrrell added a comment - - edited

          Hey Stefaan, I am not too sure we are on the same page.. Standard Roo code doesn't generate a *_Roo_GAE.aj aspect.

          Show
          James Tyrrell added a comment - - edited Hey Stefaan, I am not too sure we are on the same page.. Standard Roo code doesn't generate a *_Roo_GAE.aj aspect.
          Hide
          Stefaan Vanderheyden added a comment -

          After further investigation, it appears that several features in Roo are broken by using String ids:

          • primaryRenderer in *MobileListView.java;
          • get/set* in Roo_JavaBean.aj relies on a longIds ArrayList<Long> and used key.getId(), instead of getName(), regardless of the id type;

          It seems like @RooEntity(identifierType = ?.class) can't be used, since Long ids are hardcoded into so many parts of Roo...

          Show
          Stefaan Vanderheyden added a comment - After further investigation, it appears that several features in Roo are broken by using String ids: primaryRenderer in *MobileListView.java; get/set* in Roo_JavaBean.aj relies on a longIds ArrayList<Long> and used key.getId(), instead of getName(), regardless of the id type; It seems like @RooEntity(identifierType = ?.class) can't be used, since Long ids are hardcoded into so many parts of Roo...
          Hide
          Stefaan Vanderheyden added a comment -

          Ooops! it looks like I still had these files in my project since I manually implemented the solution that was proposed in the forum!

          The _Roo_GAE.aj files are artifacts that were not generated by Roo.

          I will test the relationships after deleting these files and reverting back to Long ids.

          It does seem that Roo has trouble with non-Long ids, as per the comment above.

          Show
          Stefaan Vanderheyden added a comment - Ooops! it looks like I still had these files in my project since I manually implemented the solution that was proposed in the forum! The _Roo_GAE.aj files are artifacts that were not generated by Roo. I will test the relationships after deleting these files and reverting back to Long ids. It does seem that Roo has trouble with non-Long ids, as per the comment above.
          Hide
          Stefaan Vanderheyden added a comment -

          Dear James,

          Thanks for pointing out my error! When I read the forum post, I thought that Roo had implemented jaredrowell's proposal, hence I thought my _Roo_GAE files were automatically generated...

          After removing the faulty files and converting my entities' ids back to Long, Roo's scaffold worked fine.
          Sorry for pulling the alarm too quickly!

          Anyway, you may still want to keep this bug to fix the different hardcoded elements that prevent @RooEntity from working with a non-Long identifierTypes.

          BR,

          Stefaan

          Show
          Stefaan Vanderheyden added a comment - Dear James, Thanks for pointing out my error! When I read the forum post, I thought that Roo had implemented jaredrowell's proposal, hence I thought my _Roo_GAE files were automatically generated... After removing the faulty files and converting my entities' ids back to Long, Roo's scaffold worked fine. Sorry for pulling the alarm too quickly! Anyway, you may still want to keep this bug to fix the different hardcoded elements that prevent @RooEntity from working with a non-Long identifierTypes. BR, Stefaan
          Hide
          James Tyrrell added a comment -

          Hey Stefaan, no problem. Your original issue has uncovered a few things which I didn't foresee in my original code, so thank you What happens in Roo to facilitate unowned relationships is really just a work around for App Engine JPA limitations. I have had a look at what would be required to allow other identifier types and I will try to get this in time for the next release, though, I will most likely close this issue and transition your request to an Improvement issue type.

          Show
          James Tyrrell added a comment - Hey Stefaan, no problem. Your original issue has uncovered a few things which I didn't foresee in my original code, so thank you What happens in Roo to facilitate unowned relationships is really just a work around for App Engine JPA limitations. I have had a look at what would be required to allow other identifier types and I will try to get this in time for the next release, though, I will most likely close this issue and transition your request to an Improvement issue type.
          Hide
          Stefaan Vanderheyden added a comment -

          Fine with me!

          Keep up the good work on Roo - each release is a giant step forward.

          Show
          Stefaan Vanderheyden added a comment - Fine with me! Keep up the good work on Roo - each release is a giant step forward.
          Hide
          James Tyrrell added a comment -

          I have created an Improvement issue in ROO-2242, which keep the discussion going with regards to id type limitations in the current GWT application.

          Show
          James Tyrrell added a comment - I have created an Improvement issue in ROO-2242 , which keep the discussion going with regards to id type limitations in the current GWT application.

            People

            • Assignee:
              James Tyrrell
              Reporter:
              Stefaan Vanderheyden
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: