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 none class to multiple tables
PostPosted: Wed Jul 06, 2005 10:34 am 
Newbie

Joined: Fri Jun 10, 2005 7:59 am
Posts: 5
Hi all

I am using hibernate 3

here is my mapping file

<?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="Dept" table="infozeal5.DEPT">
<id name="dept_id" column="dept_id" type="long" >

<generator class="assigned">

</generator>

</id>
<property name="dname" column="DNAME" type="string"/>
<property name="location" column="LOCATION" type="string"/>
<property name="dt" column="dt" type="long"/>

<join table="infozeal5.DADD" inverse="false">
<key property-ref="dt" column="dt"/>
<property name="dadd" column="DADD" type="string"/>
</join>
</class>

</hibernate-mapping>



This is my code



Session session = instance.sessionFactory.openSession();
Transaction tx = session.beginTransaction();

Dept dt=new Dept();
dt.setDept_id(4002);
dt.setDname("Marketing");
dt.setLocation("Atlanta");
dt.setDt(6002);
dt.setDadd("US");

session.save(dt);
tx.commit();

This is storing record in the both tables dept and dadd,

But the dt value in the Dadd table is storing dept_id of dept table.

I want to store dt value of Dept table into Dadd table

I need storage data as follows
DEPT TABLE
Dept_Id: 4002
DName: Marketing
Location: Atlanta
Dt:6002

DADD TABLE
Dt:6002
Dadd: US

Please kindly help me

Regards
Rishi


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 11:28 am 
Newbie

Joined: Fri Jun 10, 2005 7:59 am
Posts: 5
sorry !! I typed the subject incorrectly,

It is One class to many tables


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.