This content has been marked as final.
Show 3 replies
-
1. Re: DB inheritance mapping
joblini Nov 1, 2008 3:02 AM (in response to ipazmino)Hi, try the Hibernate user forum.
-
2. Re: DB inheritance mapping
ipazmino Nov 4, 2008 5:12 PM (in response to ipazmino)Hi,
What I should do to make this hierarchy work as I want it to, I need to add some directives like
<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>
in the mapping descriptor for hibernate.
How can I modify the reveng.xml or persistence.xml file, so that I can have this configuration done when I generate the entities with the seam-gen tool?Thanks in advance
IP
-
3. Re: DB inheritance mapping
benc.benc.alumni.psu.edu Nov 4, 2008 9:28 PM (in response to ipazmino)Or you can use annotations. I've set it up to put all three in one table below.
@Entity @Table(name = "person") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.INTEGER) abstract class Person { private String firstname; private String lastname; //getters & setters } @Entity @Table(name = "person") @DiscriminatorValue(value = "0") class User extends Person { private String username; private String password; //getters & setters } @Entity @Table(name = "person") @DiscriminatorValue(value = "1") class Visitor extends Person { private Date visitDate; //getters & setters }