[jboss-user] [JBoss Tools (users)] - DB inheritance mapping

ipazmino do-not-reply at jboss.com
Tue Nov 4 11:13:58 EST 2008


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4186750#4186750

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4186750



More information about the jboss-user mailing list