Uploaded image for project: 'z - Hibernate Annotations'
  1. ANN-467

Inheritence of Embedded objects (@Embeddable)

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JBoss 4.0.4, MYSQL 5.0.18, Java JDK 1.5.0_06
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Hi there @Hibernate (must be a pretty often repeated joke in here...)

      I have an @Embeddable object AllocationId which extends another @Embeddable
      object (GenericId). AllocationId, is simply a marker class and has NO attributes in it,
      while all attributes (String id; which I want to persist) are in GenericId (inherited in AllocationId).

      I get the following exception:

      org.hibernate.AnnotationException: com.xxx.yyy.AllocationId has no persistent id property
      at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1714)
      at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1171)
      at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:706)
      at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
      at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
      at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1207)
      at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:844)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:382)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
      at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:102)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor144.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      Any Ideas ?

      Code snippets as follow:

      @Embeddable
      public final class AllocationId extends GenericId {

      // ... serial UID here - removed as considered somewhat sensitive ...

      /**

      • @param id
        */
        public AllocationId(final String id) { super(id); }

        }

      @Embeddable
      public abstract class GenericId implements Serializable {

      /**

      • The actual Id
        */
        protected String id; // THIS IS NOT BEING 'SEEN' AS INSIDE AllocationId

      /**

      • Constructor to create a generic Id.
      • Syntactic checks are performed here (not null and empty string)
      • @param allocationId The allocation Id
        */
        protected GenericId(final String id) { validate(id); this.id = id; }

      /**

      • Performs syntactic checking of the generic id
      • @param id may not be null or empty ""
        */
        private void validate(final String id) throws IllegalArgumentException {

      if (id == null)

      { throw new IllegalArgumentException("id cannot be null"); }

      if (id.trim().length() == 0)

      { throw new IllegalArgumentException("id cannot be length 0"); }

      }

      /**

      • @return the id
        */
        public String getId() { return this.id; }

      @Override
      public String toString()

      { return getId(); }

      // some less interesting code here .equals overrides etc.
      }

      Let me know.

      Many Thanks - for your attention and for your GREAT product,
      Malta (MT).

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: