The intermediate object can be mapped in the way Erick said. 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.
P.S. Frans, when you have time please explain me your first question; thanks. 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]<nhusers%[email protected]> > > <mailto:nhusers%[email protected]<nhusers%[email protected]> > > > > <nhusers%[email protected]<nhusers%[email protected]> > > <mailto:nhusers%[email protected]<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]<nhusers%[email protected]> > > <mailto:nhusers%[email protected]<nhusers%[email protected]> > > > > <nhusers%[email protected]<nhusers%[email protected]> > > <mailto:nhusers%[email protected]<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]<nhusers%[email protected]> > > <mailto:nhusers%[email protected]<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]<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]<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.
