JPA @Embedded and @Embeddable

edited November 2011 in Round-Trip-Engineering NG
Is there an easy way to define a "composite" association between two JPA1 entities which will create one as an @Embeddable object to its "parent"? In an effort to duplicate what the example class diagram contains (UML Lab Shop Example), I tried to "Edit Association" from the default "Composition" association line to remove "Navigable" option so that the association mimicked that found in the example, but this still did not produce any @Embeddable object related to the @Entity associated.

Comments

  • Hi Bloo,

    That's simple - you just have to apply the "PersistentPart" stereotype on the entity: select the entity and choose the stereotype in the "Stereotypes" tab in the properties view. This stereotype has the UML Property "Part Type". "Embeddable" is the default value of that property.

    The Association itself must be a uni-directional composition (to 1), as you already descriped. I attached a screenshot of how the complete pattern should look like.

    Best regards
    Manuel
  • This is the screenshot I mentioned.
  • Hi Manuel,

    I don't see the screenshot attached, but I added the Stereotype and it worked as you described. Thanks for the response!

    -B
  • Uh, it seems my internet connection did not manage to submit the screenshot (I was in a train)... Glad it worked nevertheless.
    EmbeddableExample.png
    353 x 74 - 4K
Sign In or Register to comment.