4 Replies Latest reply on Feb 25, 2005 7:40 AM by Ivan Pechacek

    Way Cool - Entity Base Relationships

    Mike Duffy Novice

      Assume that every table in your system data base begins with the following four columns: created, updated, updatedByID, dataSourceTypeCode.

      In the JBoss EJB 3.0 Preview Edition you can create an entity base class that maps to the four general column names (do not annotate the class itself as an entity, that causes a mapping error; just annotate the getters that correspond to the columns).

      As long as you are consistent with your four column names across all the tables in your system, all of your Entity Beans can extend the base class.

      In essence, this gives you a way to create classes that have a generic inheritance across tables with common column names.


        • 1. Re: Way Cool - Entity Base Relationships
          Grayson Pierce Newbie

          I did exactly that but seem to get null values for the inherited fields. I created a class without Entity annotation that only has the getter/setter methods that an entity class extends. The entity inherites the getter/setter methods just fine and even the SQL debug shows the inherited columns being called as part of the select statement however when doing the get from a remote client I seem to get nulls for inherited fields but actual values for the "native" fields.

          The tutorial example seems to be inheritance between two entity beans and the only thing different in my case is I don't want the parent class persisted.

          Any idea, what's going on?

          • 2. Re: Way Cool - Entity Base Relationships
            Mike Duffy Novice

            If you don't want the fields in the parent class persisted, try marking them as @Transient

            Please let me know if this works.


            • 3. Re: Way Cool - Entity Base Relationships
              Grayson Pierce Newbie

              Hello Mike

              Thanks for the quick response. I'm not sure how @Transient would work since I don't want the entire bean persisted and not just individual fields.
              If you mark all fields transient does the entire bean become transient?

              However my mistake was that the parent class didn't have

              implements java.io.Serializable

              Once I put this in it started working and didn't need any another annotations including @Entity.

              Thanks agian.

              • 4. Re: Way Cool - Entity Base Relationships
                Ivan Pechacek Newbie

                I am trying to do the same in the latest preview 3 but I am getting the folowing error while deployed:

                12:34:40,375 ERROR [Ejb3Module] Starting failed jboss.j2ee:service=EJB3,module=evaluate.ejb3
                at org.jboss.ejb3.entity.EntityToHibernateXml.getDeclaredEntityProperties(EntityToHibernateXml.java:400)

                I have tried using @Entity, @Column and also without them but same results every time...

                Any idea how to solve it?