Hi Mikael,

Thanks for the feedback. I'll try your suggestions. As for
PrimaryManagerFk, that's the name of the column that holds the foreign
key (guid). The Fk convention is something I use to clearly identify
foreign keys by looking at column names.

Re: 3. yeah, I'm on an existing DB. I could try using the mapping to
create my DB, I'll look into that if 1 and 2 don't work.

On Aug 11, 10:34 am, Mikael Henriksson <[email protected]> wrote:
> I have had a similar problem you are using
> KeyColumnNames.Add("PrimaryManagerFk") which looks like a foreign key to me
> instead of a column name. However I ended up specifying every thing I could
> think of to make it work.
>
>    1. .References<Manager>(x => x.PrimaryManager); >> .References<Manager>(x
>    => x.PrimaryManager, "*ColumnName*");
>    2. mapping.JoinedSubClass< Manager>("BusinessId")
>          .HasMany(x => x.ManagedCustomers)
>          .KeyColumnNames.Clear()
>          .KeyColumnNames.Add("*ColumnName*")
>          .Inverse();
>    3. To me it looks like you are trying to use an existing MS SQL database
>    or whatever. Another thing to try would be to generate a database from your
>    mappings and see what you end up with. That's how I usually find my errors.
>
> On Tue, Aug 11, 2009 at 4:11 PM, Chris Fazeli <[email protected]> wrote:
>
> > Is the only solution here to use a manually created an HBM file for my
> > Business entity and its joined subclasses?
>
> > Has no one else seen this problem?
>
> > On Aug 5, 2:25 pm, Chris Fazeli <[email protected]> wrote:
> > > Hi again,
>
> > > Can anyone give this a second look and give me even a guess? I'd
> > > appreciate it.
>
> > > Thanks,
> > > -Chris
>
> > > On Aug 3, 12:27 pm,ChrisFazeli<[email protected]> wrote:
>
> > > > Hi,
>
> > > > I posted about this in another post, but thought it might have gotten
> > > > buried under the wrong "Subject":
> >http://groups.google.com/group/fluent-nhibernate/browse_thread/thread...
>
> > > > I have two tables that have two separate references to each other:
> > > > 1-to-many: 1 Manager to Many Customers (as PrimaryManagers)
> > > > many-to-many: Many Managers to Many Customers (as SecondaryManagers)
>
> > > > Both of my domain model entities (Manager and Customer) inherit from
> > > > the same base Business class (joined subclasses).
>
> > > > While I can get the many-to-many to map correctly using an automapping
> > > > override on the Business class, I cannot get the 1-to-many to map
> > > > correctly:
>
> > > > // Does not work correctly
> > > > mapping.JoinedSubClass<Manager>("BusinessId")
> > > >        .HasMany(x => x.ManagedCustomers)
> > > >        .KeyColumnNames.Clear()
> > > >        .KeyColumnNames.Add("PrimaryManagerFk")
> > > >        .Inverse();
>
> > > > // Works in this direction
> > > > mapping.JoinedSubClass<Customer>("BusinessId")
> > > >        .References<Manager>(x => x.PrimaryManager);
>
> > > > Here's the output I get:
>
> > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> > > > access="">
> > > >   <class name="Project.Business, Project, Version=1.0.0.0,
> > > > Culture=neutral, PublicKeyToken=null" table="Businesses"
> > > > xmlns="urn:nhibernate-mapping-2.2">
> > > >     ...
> > > >     <joined-subclass name="Project.Manager, Project, Version=1.0.0.0,
> > > > Culture=neutral, PublicKeyToken=null" table="Managers">
> > > >       <key column="BusinessId" />
> > > >      ...
> > > >       <bag name="Customers" inverse="true"
> > > > table="ManagersToCustomers">
> > > >         <key column="ManagerFk" />
> > > >         <many-to-many column="CustomerFk" class="Project.Customer,
> > > > Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
> > > >       </bag>
>
> > > > <!-- INCORRECT MAPPING STARTS -->
>
> > > >       <bag name="ManagedCustomers" inverse="true">
> > > >         <key column="ManagerFk" />
> > > >         <one-to-many class="Project.Customer, Project,
> > > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
> > > >       </bag>
>
> > > > <!-- INCORRECT MAPPING STOPS -->
>
> > > >     </joined-subclass>
> > > >     <joined-subclass name="Project.Customer, Project, Version=1.0.0.0,
> > > > Culture=neutral, PublicKeyToken=null" table="Customers">
> > > >       <key column="BusinessId" />
> > > >       ...
> > > >       <bag name="SecondaryManagers" table="ManagersToCustomers">
> > > >         <key column="CustomerFk" />
> > > >         <many-to-many column="ManagerFk" class="Project.Manager,
> > > > Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
> > > >       </bag>
> > > >       <many-to-one name="PrimaryManager" column="PrimaryManagerFk" />
> > > >       ...
> > > >     </joined-subclass>
> > > >   </class>
> > > > </hibernate-mapping>
>
> > > > What am I doing wrong? I've tried every tutorial and example, but
> > > > can't get the KeyColumnName to be correct.
> > > > -Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to