-->
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.  [ 6 posts ] 
Author Message
 Post subject: Mapping two columns with different names
PostPosted: Tue Nov 25, 2003 1:17 pm 
Newbie

Joined: Tue Nov 25, 2003 1:12 pm
Posts: 4
Location: London
All my mapping tables so far have been on fields with the same name.

I now need to map two fields with different names.

Have a mapping file for the table SiteObj that has a field called SiteId that I need to map to a field called NAVSITEID ina table called NavPageMapV

...........
<!-- bi-directional one-to-many association to NavPageMapV -->
<set name="navPageMapVs" lazy="true" inverse="true">
<key>
<column name="SITEID"/>
</key>
<one-to-many class="com.sportcentric.data.isite.views.NavPageMapV"/>
</set>
.................

The column I want to map it to in the table NavPageMapV is called NAVSITEID. Where do I define this.


Top
 Profile  
 
 Post subject: ???
PostPosted: Tue Nov 25, 2003 1:33 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Can you provide a little more detail, I'm confused about what you are trying to do.

Are you trying to map a field that is not the primary key of the parent to be the key to the children?

I'm guessing from what you've posted for a mapping that all you might need to do would be change your <column.../> to <column name="NAVSITEID"/> providing that the values in that column match the key of the parent.


Top
 Profile  
 
 Post subject: Linking fields with different names
PostPosted: Wed Nov 26, 2003 6:14 am 
Newbie

Joined: Tue Nov 25, 2003 1:12 pm
Posts: 4
Location: London
David

Am new to this so apologies if not explained very well.

I have a view with a key field of SiteId that I need to map to a view with children (one-to-many) that has a matching field called NavSiteId. All of the documentation seems to use examples where the linking fields have the same name.

I will also need to do this for a number of non-key fields that link to other child tables with fields of different names:


View SITE
SiteId
Name
Desc
SiteSchemeId

View NAVPAGE
NavId
Name
NavSiteId

View SCHEME
SchemeId
SchemeName


View SITE has a one-to-many with NAVPAGE linking SITE.SiteId to NAVPAGE.NavSiteId

View SITE has a one-to-many with SCHEME linking SITE.SiteSchemeId to SCHEME.SchemeId


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2003 9:29 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
I guess you can do

<set name="navPageMapVs" lazy="true" inverse="true">
<key column="NAVSITEID" />
<one-to-many class="com.sportcentric.data.isite.views.NavPageMapV"/>
</set>

--
the column NAVSITEID should refer to NAVPAGE's NavSiteId attribute.

HTH,
Alex.


Top
 Profile  
 
 Post subject: Mapping two columns with different names
PostPosted: Wed Nov 26, 2003 10:16 am 
Newbie

Joined: Tue Nov 25, 2003 1:12 pm
Posts: 4
Location: London
Are you trying to map a field that is not the primary key of the parent to be the key to the children?

Yes I am, is this possible?


Top
 Profile  
 
 Post subject: I think you can't do it without a x-ref
PostPosted: Wed Nov 26, 2003 2:12 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Quote:
Are you trying to map a field that is not the primary key of the parent to be the key to the children?

Yes I am, is this possible?


I tried to do this a few months ago and was told at that time that it was not allowed because it represents a bad data model so the only way around it that I know of is to have a cross reference between the two tables (or in your case views) that does provide keying from the parent's primary key to some field on the children (either with or without a finer grained object model).

Your mapping from SITE.SiteId to NAVPAGE.NavSiteId should be just fine (much like ashneyde described) but for your mapping from SITE.SiteSchemeId to SCHEME.SchemeId you would need a cross reference that matched up the primary keys.

It actually looks to me like your relationship from SITE to SCHEME could be a many-to-many instead of a one-to-many but I think you would still need a cross reference (which you can easily make as another view and you don't need an object for it because its just needed for mapping the relationship).


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