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
|
|