Announcement Announcement Module
No announcement yet.
OpenJPA: @Embedded vs @EmbeddedCollection Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenJPA: @Embedded vs @EmbeddedCollection


    I am trying to decide which annotation to use. Can you offer your opinion?

    One of my entities (let's call it Balance) contains several embedded objects of the same type (let's call it Amount). Right now there are 7 of these objects inside the Balance entity. I override the column names of Amount to be able to store all of this data in the Balance table in the database.

    The Amount objects for one Balances are often treated as a group, so, conceptually, they could be a collection. In fact, I really want to use @EmbeddedCollection annotation and map these objects as a Map<AmountType, Amount> inside the Balance, where AmountType would be an enumeration with possible amount types.

    The problem is, if I do that - I will not be able to store all of the data in the same table (correct?). I would need to have a separate tables for my Balance and for Amounts linked to the Balances. This means JOINs when working with the data... What would you do here? Would you map these objects as an @EmbeddedCollection?

    Thank you.