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 hbm file (foreign key)
PostPosted: Wed Aug 18, 2010 2:42 am 
Newbie

Joined: Wed Aug 18, 2010 2:16 am
Posts: 1
Hi all of you....
i have one problem in hibernate mapping file.
I have a one table "PARTNERBRANCHSERVICECITIES" and one VIEW named "VW_MSLOCATIONS" with columns :
AREAID int
AREA varchar
CITYID int
CITY varchar
STATEID int
STATE varchar
COUNTRYID int
COUNTRY varchar

the AREAID is primary key and assigned, but there is another table named "PARTNERBRANCHSERVICECITIES"
I want to relation two table with column "CITYID" but Hibernate use my primary key to join two table. how can I join two table with another column in a table, i dont want to join with primary key column.

my mapping in LocationDetailsEntity.hbm.xml is:(LocationDetailsEntity class also same)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class mutable="false" name="com.lsp.lens.common.entity.LocationDetailsEntity" table="VW_MSLOCATIONS">
<!--<cache usage="read-only"/>-->
<id column="AREAID" name="areaId">
<generator class="assigned"/>
</id>
<property column="AREA" name="areaName"/>
<property column="CITYID" name="cityId"/>
<property column="CITY" name="cityName"/>
<property column="STATEID" name="stateId"/>
<property column="STATE" name="stateName"/>
<property column="COUNTRYID" name="countryId"/>
<property column="COUNTRY" name="countryName"/>
</class>
</hibernate-mapping>

and PartnerBranchCityEntity.hbm.xml is like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.lsp.lens.partner.entity.PartnerBranchCityEntity" table="PARTNERBRANCHSERVICECITIES">
<id column="Id" name="id">
<generator class="increment"/>
</id>
<property column="PartnerBranchID" name="partnerBranchID"/>
<many-to-one cascade="none" class="com.lsp.lens.common.entity.LocationDetailsEntity" column="CityID" name="locationDetailsEntity" not-null="true"/>
</class>
</hibernate-mapping>

where i am going to wrong please help me ....

Thanks in advanced
Rajesh Kardile
+91-9960689600


Top
 Profile  
 
 Post subject: Re: mapping two hbm file (foreign key)
PostPosted: Wed Mar 02, 2011 7:57 am 
Newbie

Joined: Wed Jan 19, 2011 6:30 am
Posts: 10
Hi There,

I am also facing same issue even I added mapping in .cfg file for my both hbm files.

If an one have resolved, please let me know....

Thanx in advance.
Navnath Kumbhar.


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.