> The intermediate object can be mapped in the way Erick said.
Yes, but that's not creating a m:n relationship between the two pk
sides of the m:n relationships.
Take northwind, the entities 'Customer', 'Order' and 'Employee'.
Order has a m:1 with Customer and with Employee, so a m:n relationship
exists between Customer and Employee (via Order). How do I map this Customer
m:n Employee relationship? I couldn't find anything about that in the
manual, as 'Order' isn't a 'hidden' entity, it's a normal entity like any
other.
I think Jim runs into this same problem.
Note: Customer.Employees is readonly, as saving a new relationship
requires you to fill in the fields of 'Order', the intermediate entity. I
think this is why it's not mappable, but I'd like to know for sure.
> In NH you can map a many-to-many using <idbag> and then transform the
> "hidden" intermediate table to a table where persist an entity with its
> properties. Doing so you have to change the previous many-to-many
relations
> in a one-to-many with the intermediate entity.
I re-read these 4 lines a couple of times, but I'm sorry, I don't
get what you mean here :). Is there an example of this somewhere, other than
the m:n documentation which only talks about the situation where the
intermediate entity is hidden (so no class mapped onto the intermediate
table) ?
> P.S. Frans, when you have time please explain me your first question;
> thanks.
Jim complained you being rude. IMHO you were still rude to Jim in
your opening questions. That's all. I was just wondering why you'd do that,
as annoyed users do more harm than good to any software system, and it's
unnecessary: (generally speaking, so Jim, this isn't about you ;)) if a user
is stupid, stubborn and retarded, still it's beneficial to stay polite, even
if that takes a lot of energy ;) -> users who are helped or at least get the
feeling they're helped and people put effort in helping them, are willing to
recommend your work to others. Annoyed users don't, in fact they'll whine
and complain to others, how unlogical that might be even, as the user is
likely the cause of the issue. Anyway, I was just wondering, that's all ;).
Do what you want with this advice. ;)
FB
ps: I tried to lookup the m:n stuff again in the docs, but nhforge.org is
down again... (domain is up, no content served)
>
> On Sun, Jul 25, 2010 at 3:24 PM, Frans Bouma <[email protected]> wrote:
>
>
> > If nobody is answering you, which can be the reason ?
> > nobody loves you ?
>
>
> why annoy the users of your work?
>
>
> > try to follow my advise:
> > send here your mappings and your classes and explain your problem.
> >
> > The error in short:
> > You are using a specific persistent entity that represent the
many-
> to-many
> > relation, this class has its others properties, but in the mapping
> of
> Author
> > and Book you are not using the class representing the relation.
> > Before check if there is a bug or not you have to map your domain
> correctly.
> >
> > Send here your mappings and try to explain your situation and you
> will see
> > that somebody loves you.
>
>
> I always thought objectified relationships (m:n relationships
> with
> an intermediate entity with fields which aren't part of the
> pk/identifying
> fields) weren't supported by nhibernate, only pure M:N (so
> intermediate
> entity consists only of pk fields which are the FK fields in the two
> m:1
> relationships of which it is the fk side) relationships, and in such
> a way
> that the intermediate entity is hidden as well (so no class is
> mapped)
>
> Example:
> Employee:
> - ID *
> - FirstName
> - LastName
>
> Department:
> - ID *
> - Name
>
> Pure m:n, supported:
> extra table (intermediate entity) but no mapped class on this table:
> EmployeeDepartment
> - EmployeeID *
> - DepartmentID *
>
> Objectified m:n, not supported (at least I couldn't find info about
> this)
> Extra table (intermediate entity), with mapped class:
> EmployeeDepartment
> - EmployeeID *
> - DepartmentID *
> - StartDate
>
> IMHO, Jim wants this objectified relationship scenario,
> however that
> requires that the intermediate entity has no mapped class.
>
> FB
>
>
>
> >
> > On Sun, Jul 25, 2010 at 12:46 PM, Jim Geurts <[email protected]>
> wrote:
> >
> >
> > I titled this post based on your comment here:
> > http://216.121.112.228/browse/NH-2212.
> > The classes, mappings, and nunit test are all included in
the
> > attachment in the JIRA issue.
> >
> >
> >
> >
> > On Jul 25, 6:42 am, Fabio Maulo <[email protected]>
wrote:
> > > The title of this thread say: "when the relation is
> represented by
> > a class
> > > with additional properties"
> > >
> > > Where is the class, and its mapping, representing the
many-
> to-many
> > relation
> > > ?
> > >
> > >
> > >
> > >
> > >
> >
> > > On Sat, Jul 24, 2010 at 6:08 PM, Jim Geurts
> <[email protected]>
> > wrote:
> > > > I don't mean to be rude, but you closed the bug. You
> asked me
> to
> > post
> > > > the issue to the list, which I did previously, multiple
> times...
> > > > without reply. I created unit tests that reproduce this
> issue,
> > yet
> > > > still no reply from anyone. It seems like a common
issue
> that
> > people
> > > > are going to run across. I'm just looking for either a
> > description of
> > > > how I'm mapping things wrong, or how to properly
> accomplish this
> > type
> > > > of situation...
> > >
> > > > Thanks,
> > >
> > > > Jim
> > >
> > > > On Jul 23, 6:49 pm, Fabio Maulo <[email protected]>
> wrote:
> > > > > Perhaps with the whole mapping and classes somebody
> else may
> > help you.
> > >
> > > > > --
> > > > > Fabio Maulo
> > >
> > > > > El 23/07/2010, a las 13:01, Jim Geurts
> <[email protected]>
> > escribió:
> > >
> > > > > > Fabio,
> > >
> > > > > > Since this is apparently not a bug and is a mapping
> error
> > according to
> > > > > > NH-2212, can you show me the light on what I'm doing
> wrong?
> > >
> > > > > > I have a bag defined for a many-to-many list:
> > > > > > <class name="Author" table="Authors">
> > > > > > <id name="Id" column="AuthorId">
> > > > > > <generator class="identity" />
> > > > > > </id>
> > > > > > <property name="Name" />
> > > > > > <bag name="Books" table="Author_Book_Map"
> > where="IsDeleted=0"
> > > > > > fetch="join">
> > > > > > <key column="AuthorId" />
> > > > > > <many-to-many class="Book" column="BookId"
> > > > > > where="IsDeleted=0" />
> > > > > > </bag>
> > > > > > </class>
> > >
> > > > > > Now, if I return all author objects (using something
> like
> > > > > > Session.Query<Author>().List<Author>()), I will get
> what
> > initially
> > > > > > appeared to be duplicate Author records: The extra
> author
> > objects are
> > > > > > created when an author is mapped to multiple books
> that vary
> > by
> > > > > > IsDeleted. Rather than creating one Author object
> with an
> > enumerable
> > > > > > that contains only the books with IsDeleted = 0, it
> will
> > create two
> > > > > > author objects. The first author
> > > > > > object has a Books enumerable that contains books
> with
> > IsDeleted = 0.
> > > > > > The second author object will contain an enumerable
> of null
> > book
> > > > > > objects.
> > >
> > > > > > I'm thinking part of the problem stems from the map
> table
> > objects
> > > > > > linking to rows that do not meet the many-to-many
> where
> > condition. Is
> > > > > > this a configuration issue or something else?
> > >
> > > > > > Thanks,
> > >
> > > > > > Jim
> > >
> > > > > > --
> > > > > > You received this message because you are subscribed
> to the
> > Google
> > > > Groups "nhusers" group.
> > > > > > To post to this group, send email to
> > [email protected].
> > > > > > To unsubscribe from this group, send email to
> >
> > > > [email protected]
> <mailto:nhusers%[email protected]>
>
> > <mailto:nhusers%[email protected]
> <mailto:nhusers%[email protected]> >
> > <nhusers%[email protected]
> <mailto:nhusers%[email protected]>
> > <mailto:nhusers%[email protected]
> <mailto:nhusers%[email protected]> > >
>
> >
> > > > .
> > > > > > For more options, visit this group athttp://
> > > > groups.google.com/group/nhusers?hl=en.
> > >
> > > > --
> > > > You received this message because you are subscribed to
> the
> > Google Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to
> [email protected].
> > > > To unsubscribe from this group, send email to
> >
> > > > [email protected]
> <mailto:nhusers%[email protected]>
>
> > <mailto:nhusers%[email protected]
> <mailto:nhusers%[email protected]> >
> > <nhusers%[email protected]
> <mailto:nhusers%[email protected]>
> > <mailto:nhusers%[email protected]
> <mailto:nhusers%[email protected]> > >
>
> >
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
> > >
> > > --
> > > Fabio Maulo
> >
> >
> > --
> >
> > You received this message because you are subscribed to the
> Google
> > Groups "nhusers" group.
> > To post to this group, send email to
> [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]
> <mailto:nhusers%[email protected]>
>
> > <mailto:nhusers%[email protected]
> <mailto:nhusers%[email protected]> > .
>
> > For more options, visit this group at
> > http://groups.google.com/group/nhusers?hl=en.
> >
> >
> >
> >
> >
> >
> > --
> > Fabio Maulo
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]
> <mailto:nhusers%[email protected]> .
> > For more options, visit this group at
> > http://groups.google.com/group/nhusers?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]
> <mailto:nhusers%[email protected]> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>
>
>
>
> --
> Fabio Maulo
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.