| Author |
HBM mapping Problem
|
vivek kumar jaiswal
Greenhorn
Joined: Jul 31, 2008
Posts: 24
|
|
Hello Ranchers,
Please see this mapping.
<class name="User" table="users">
<id name="id" column="id">
<generator class="identity" />
</id>
<discriminator column="user_type" type="string" />
<version name="version" column="version" />
<bag name="pchDetails" table="user_pch" lazy="false" inverse="true">
<key column="user_id"/>
<many-to-many column="pch" class="PchDetail"/>
</bag>
<bag name="workcenters" table="user_workcenter" inverse="true"
lazy="false">
<key column="user_id" />
<many-to-many column="workcenter_id" class="Workcenter" />
</bag>
<property name="firstName" column="first_name" />
<property name="middleName" column="middle_name" />
<property name="lastName" column="last_name" />
<property name="tokenNumber" column="token_number" />
<property name="userId" column="user_id" />
<property name="hashedPassword" column="hashed_password" />
<property name="randomCookie" column="random_cookie" />
<property name="userState" column="user_state" />
</class>
<class name="UserPch" table="user_pch">
<composite-id>
<key-property name="pchDetail" column="pch"/>
<key-property name="user" type="string" column="user_id"/>
</composite-id>
<many-to-one name="user" class="User" lazy="false" column="user_id" insert="false" update="false"/>
<many-to-one name="pchDetail" class="PchDetail" lazy="false" column="pch" insert="false" update="false"/>
<property name="tdate" type="java.util.Date" column="tdate"/>
</class>
<class name="PchDetail" table="pch_detail">
<id name="pch" column="pch"/>
<property name="pch" column="pch" insert="false" update="false"/>
</class>
Check this mapping
<bag name="pchDetails" table="user_pch" lazy="false" inverse="true">
<key column="user_id"/>
<many-to-many column="pch" class="PchDetail"/>
</bag>
The value of "user_id" column in "user_pch" table saved the value of "id" column in "users" table.
I want to save user_id column in users table to user_id column in user_pch.
Please what should I do.
regards,
vivek
|
 |
Waswani Naresh
Ranch Hand
Joined: May 01, 2008
Posts: 66
|
|
Hi Vivek,
I was not very comfortable with the concern/question that you have. I tried to simulate some thing similar using layman POJOs and mappings. Have a look at them and see if this helps to solve your problem.
Proj.java
Empl.java
EmpProj.java
Proj.hbm.xml
Empl.hbm.xml
EmplProj.hbm.xml
Main code for saving objects :
Regards,
Naresh
|
Naresh Waswani
|
 |
vivek kumar jaiswal
Greenhorn
Joined: Jul 31, 2008
Posts: 24
|
|
Dear Naresh,
thanking to replying this concern i solved this problem.
<key column="user_id" property-ref="UserId"/>
regards,
VIVEK
|
 |
 |
|
|
subject: HBM mapping Problem
|
|
|