-->
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.  [ 7 posts ] 
Author Message
 Post subject: Many-to-Many mapping example
PostPosted: Tue Mar 28, 2006 11:37 am 
Regular
Regular

Joined: Tue Feb 07, 2006 4:27 pm
Posts: 69
Hi all,

I'm obviously new to NHibernate and am having trouble getting a
many-to-many mapping working properly.

Does someone have a working sample, including table DDL for SQL Server that I can use as a reference?

I've had no luck finding any examples with a many-to-many
relationship mapped.

Thanks in advance.

Greg


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 12:36 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
check out one of my recent posts on many-to-many:

http://forum.hibernate.org/viewtopic.php?t=955973&highlight=mtom+manytomany+mm

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 12:37 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
if that doesn't work for you, then reply, and I'll muster up a working example for you. complete with SQL.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 2:10 pm 
Regular
Regular

Joined: Tue Feb 07, 2006 4:27 pm
Posts: 69
Thanks very much. I'll take a look for sure.

This appears to set up a bi-directional relationship.

It is possible to setup a uni-directional relationship

Table A navigates to Table C via the xref table B, but I don't need to
be able to go from C back to A..

Hope this makes sense.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 2:15 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
don't put the Set/List on one side, and don't provide it's mapping in that class.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 5:01 pm 
Regular
Regular

Joined: Tue Feb 07, 2006 4:27 pm
Posts: 69
Hi JT,

Using the Link you provided, I have my example working. It works on both a read and a new insert.

Thanks very much for your assistance. This is soooo much better than
writing the SQL yourself.

I've used TOPLink for Java in the Java space and am very happy that
there is a decent ORM tool for .net now and a community of developers
to collaborate with.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 5:18 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
that is good to hear - I am glad to help.


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