-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: mapping two classes to a single table
PostPosted: Fri Nov 20, 2009 8:11 am 
Newbie

Joined: Thu Nov 12, 2009 4:09 am
Posts: 2
Hi

I am new to hibernate. I want to know whether we can map multiple classes (say for example my POJO's are ClassA and ClassB) to single table( table TEST). Is it possible of mapping these two classes to one table.If possible please post the process how to achieve it.

Thanks in advance,
Srikanth


Top
 Profile  
 
 Post subject: Re: mapping two classes to a single table
PostPosted: Sun Nov 22, 2009 11:17 am 
Newbie

Joined: Thu Sep 24, 2009 11:49 am
Posts: 8
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="contact.Employee" table="emp_class" discriminator-value="employee">
<id name="id" type="int" column="empid">
<generator class="assigned"/>
</id>
<discriminator column="emp_type" type="string"/>
<property name="name">
<column name="empname"/>
</property>
<property name="sal">
<column name="empsal"/>
</property>
<subclass name="contact.SalesPerson" discriminator-value="sales person">
<property name="incentives" type="int" column="incentives"/>
</subclass>
</class>
</hibernate-mapping>

----------------------------------
u can use the table per class (Inheritance Mapping) functionality of hibernate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.