1 Reply Latest reply on Nov 5, 2008 5:06 AM by Max Rydahl Andersen

    DB inheritance mapping

    Ivan Pazmino Newbie

      Hi,

      I have a table that holds general fields, representing a generalization, and two holding specific fields, as they are specializations.

      Mapping these entitites I wish to have the following class hierarchy

      abstract class Person {
       private String firstname;
       private String lastname;
       //getters & setters
      }
      
      class User extends Person {
       private String username;
       private String password;
       //getters & setters
      }
      
      class Visitor extends Person {
       private Date visitDate;
       //getters & setters
      }


      To achieve this, I need to put the following directives in the mapping descriptor for hibernate.

      <class name="Payment" table="PAYMENT">
       <id name="id" type="long" column="PAYMENT_ID">
       <generator class="native"/>
       </id>
       <property name="amount" column="AMOUNT"/>
       ...
       <joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
       <key column="PAYMENT_ID"/>
       <property name="creditCardType" column="CCTYPE"/>
       ...
       </joined-subclass>
      </class>


      How can I modify the reveng.xml file, so that i can have this configuration done when I generate the entities with the Hibernate Code Generator from JBossTools?

      Thanks in advance

      IP