3 Replies Latest reply on Mar 11, 2005 1:46 PM by Bill Burke

    Why do I need both @Emdedded and @Embeddable annotations?


      @Embeddable seems to have little utility.

        • 1. Re: Why do I need both @Emdedded and @Embeddable annotations
          Bill Burke Master

          I think @Embeddable is optional in the spec, not sure if it is optional in my impl though...

          @Embeddable is useful if you want to declare whether your persistent props are FIELD or PROPERTY based. Are they defined as getter/setter methods? Or should the persistence manager use fields. Get me?

          • 2. Re: Why do I need both @Emdedded and @Embeddable annotations

            @Embeddable is not optional in your implementation, it throws an NPE if you leave it out.

            Also, if I do declare @Embeddable, then having to explicitly declare @AttributeOverrides in @Embedded side seems redundant in usual cases.

            The simplest case would be to declare an @Embedded property, and if nothing else is declared default to AccessType = PROPERTY on the property's type (no need to have @Embeddable annotation) and AttributeOverrides default to all properties of the @Embedded type. Assuming this is the most common use case (JavaBean class), only a single @Embedded annotation is required. Only cases where default behavior is not desired, should more annotations be necessary.

            At the moment I need to annotate @Embedded with @AttributeOverrides and the JavaBean with an @Embeddable annotation just to get a simple one-to-one JavaBean property to table column mapping done.

            • 3. Re: Why do I need both @Emdedded and @Embeddable annotations
              Bill Burke Master

              yes, i know. There is a jira task on this.