-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unidirectional Mapping - Help needed on Cascade Options
PostPosted: Tue May 02, 2006 5:16 am 
Newbie

Joined: Tue May 02, 2006 2:39 am
Posts: 2
Hi,

Please forgive of the question is stupid...I am a beginner...
How should I map to suit this situation?

I have two entities Employee and Location. The Location table in the database
has to be just used as a static lookup table to populate a drop down box in my JSP.

The problem is that when I fetch the details from the database, the employee object should come with the location object as a child, but when i try to save an employee object, the employee table should just get updated with the foreign key alone, a new location object should not be inserted.

Here is the table structure
Code:
Table EMPLOYEE

Employee_Id
Employee_Name
Employee_Role
Location_CD - FK (Location.Location_CD)

Table Location

Location_CD
Location_Name


Here are the mapping files:
Code:
EMPLOYEE
    <class name="Employee" table="EMPLOYEE">
        <id name="employeeID" column="Employee_Id">
        </id>
        <property name="empName" column="Employee_Name"/>
        <property name="empRole" column="Employee_Role"/>
        <many-to-one name="empLocation"
         column="Location_CD"
         unique="true"
         fetch="join"/>
    </class>

LOCATION

    <class name="Location" table="Location">
        <id name="locationCD" column="Location_CD">
        </id>      
        <property name="locationName" column="Location_Name"/>
    </class>

How should i modify the mapping file of Employee so that the child location is not saved during save of employee? But i do need the location object during the select operation.

Any help is greatly appreciated!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 9:55 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
have you tried cascade="none" ?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 11:42 pm 
Newbie

Joined: Tue May 02, 2006 2:39 am
Posts: 2
Thanks...Cascade="none" works...just removing cascade is also the same.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.