Announcement Announcement Module
No announcement yet.
how to use @Embeddable with Roo Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to use @Embeddable with Roo

    If I am trying to create an embeddable entity but I ma not sure how to go about it.

    Do I just go ahead do the "entity" command and then remove the @Entity and add the @Embeddable annotation? Or I have to declare the class manually without using Roo?


  • #2
    In Roo 1.1 you will be able to annotate a class with @RooIdentifier and specify your composite key fields. Roo will create an ITD with the @Embeddable annotation. You can then add this to the entity class's @RooEntity annotation by specifying the class in the identifierClass attribute. Roo will then generate the @EmbeddedId in the entity's ITD. If you decide to change this later to a simple Long primary key, Roo will change the @EmbeddedId back to @Id.

    This code is in trunk now if you want to try. However, we are still to get the UI layer working with composite keys.

    In 1.0.2 you will have to push-in refactor the entity ITD and declare the @EmbeddedId in the entity class as Roo won't reomve the @Id field from the .aj file even if you have specified a field annotated with @EmbeddedId.

    Last edited by Alan Stewart; Apr 23rd, 2010, 08:57 PM.


    • #3
      hi Alan,

      Thank you for the info, it took me awhile to get back to my side project. What I am looking for is if Roo is supporting pure embeddable classes that does not have its own identity?

      My project is GWT enabled and it seems to add another layer of complication. I tried the following:

      class EffectiveDate {...}

      class A {
      private EffectiveDate dateRange;

      However Roo/GWT doesn't like that. I have resort to interface now instead of embeddable, since Roo auto gen the getters&setters, it isn't too much work to just define the fields so Roo auto gen the accessors that matches the interface.

      Any simple solution or I have to have identity on the EffectiveDate class?



      • #4
        At this point, we're just offering support of @EmbeddedId's for the database reverse engineering feature (ROO-435), but please log a Jira improvement request for embedded classes.


        • #5
          Improvement request created as requested:


          • #6
   has been completed in Git ID 400cffd7bf4e0d4a3220dd11bad2442dc35412c1.


            • #7
              Thanks Alan, I don't know how to checkout the M4 code and build the jar yet. But looking at the associated check-ins, it looks like the fix was to addnew commands to the Roo command line interface but not addressing the issue with GWT scaffolding.

              I am sorry I wasn't very clear in the issue's initial comment. But it was intended to target the GWT integration and not the plain Roo-Spring MVC integration. I have added some comment on the issue itself.

              Please let me know if I have mis-read the fix or u need more information to reproduce the problem.



              • #8
                To build Roo, install Git (there are versions available for Windows, Linux and Mac OSX).
                In a directory run

                git clone git:// roo

                Build it with mvn clean install, then run roo-dev (bootstrap) directory.

                I said in the comments of ROO-1068 to open a new ticket specifically for the GWT issue.