0 Replies Latest reply on Jan 19, 2006 7:36 PM by jnorris10

    Polymorphic @Embeddable types possible?

    jnorris10

      Consider the following example:

      If I have a Shape class which has subclasses called Square, Circle, etc. with separate data members, I would like to treat this hierarchy as @Embeddable since I don't care about database identity, just equality. However, it seems that I cannot embed the Shape type into another @Entity since it is a class hierarchy and therefore there will be a variable numbers of fields to embed in the tuple depending on the subtype. Ideally I would like to use an inheritance one-table-per-class strategy on an @Embeddable type - something that's not mentioned in the EJB3 spec.

      I can easily make Shape a real @Entity and do one of the standard inheritance strategies outlined in the spec, but then I have to worry about database identity. This will work, but it seems sub-optimal since these are really value objects. However, I can go this route and hide the identity in my implementation.

      Any suggestions? I am also open to suggestions that aren't in the EJB3 spec and require hibernate "extensions".

      Thanks.