Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:39+00:00 2026-05-22T20:51:39+00:00

I have a bi-directional, many-to-many association between EntityA and EntityB and I’m using an

  • 0

I have a bi-directional, many-to-many association between EntityA and EntityB and I’m using an association class, EntityABLink, to model this because there are other attributes about the relationship that I need to track. In addition, I also have another class that holds a reference to a specific relationship between EntityA and EntityB so I treat the association class as a full-fledged entity.

In EntityA I have a read-only property that returns a list of associated EntityB objects and, likewise, in EntityB I have a read-only property that returns a list of associated EntityA objects. Note that, for these properties, I’m hiding the fact that the association is implemented via an association class. (I also have dedicated methods for updating the relationships that hide the implementation.) Behind the scenes in both EntityA and EntityB, I have private collections of type EntityABLink.

Since a picture is worth a thousand words, here is what I have described so far:
enter image description here

(Note again that the public, read-only properties on EntityA and EntityB are not of the same type as the private members that back them up.)

So far, so good. Now I want to persist these objects to a database using Fluent NHibernate automapping overrides. When it comes to mapping, I like to think of the above using this functionally equivalent representation:
enter image description here
From this diagram, it’s clear that what I really need is two bi-directional one-to-many relationships.

In mapping the above, I figure that I need something like this:

In the EntityA automapping override:

mapping.HasMany<EntityABLink>(Reveal.Member<EntityA>(“_AssociationList”)).Inverse().AsBag().Cascade.SaveUpdate(); 
mapping.IgnoreProperty(x => x.EntityBList);

In the EntityB automapping override:

mapping.HasMany<EntityABLink>(Reveal.Member<EntityB>(“_AssociationList”)).Inverse().AsBag().Cascade.SaveUpdate(); 
mapping.IgnoreProperty(x => x.EntityAList);

In the EntityABLink automapping override:

mapping.References<EntityA>(x => x.EntityA).Not.Nullable();
mapping.References<EntityB>(x => x.EntityB).Not.Nullable();

When I try this, however, I get the following error:

“Could not find a getter for property ‘_ AssociationList’ in class ‘EntityB’.”

I must have something wrong with my mappings, but I’m not sure what. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:51:40+00:00Added an answer on May 22, 2026 at 8:51 pm

    I got it working now. So here’s the trick… I reverted back to Fluent NHibernate version 1.1 (specifically 1.1.0.685). Then, although the mapping examples that use “Reveal.Member” don’t show it as being necessary, I added “Access.Field()” to the mapping for both EntityA._AssociationList and EntityB._AssociationList. Here are the working mappings.

    In the EntityA automapping override:

    mapping.HasMany<EntityABLink>(Reveal.Member<EntityA>(“_AssociationList”)).Inverse().AsBag().Cascade.SaveUpdate().Access.Field(); 
    mapping.IgnoreProperty(x => x.EntityBList);
    

    In the EntityB automapping override:

    mapping.HasMany<EntityABLink>(Reveal.Member<EntityB>(“_AssociationList”)).Inverse().AsBag().Cascade.SaveUpdate().Access.Field(); 
    mapping.IgnoreProperty(x => x.EntityAList);
    

    In the EntityABLink automapping override:

    mapping.References<EntityA>(x => x.EntityA).Not.Nullable();
    mapping.References<EntityB>(x => x.EntityB).Not.Nullable();
    

    Once it was working in FNH 1.1, I tried upgrading to FNH 1.2. No good. I tried 1.2.0.694 as well as 1.2.0.712 and both of these still give the incorrect error message that a different “entity” (which is actually an enum!) doesn’t have an Id mapped.

    Fluent NHibernate is a wonderful tool so I hope that the bug in the latest version gets fixed. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Hibernate with JPA annotations. I have a one-directional many-to-many association that
I have a one-directional many-to-many association: the ListDefinition class has the Columns property of
We have the following two entities with many-to-many association: @Entity public class Role {
I have a bi-directional one-to-many relationship defined between Parent and Child classes. I'm looking
I have a basic has_many :through relationship that is bi-directional: calendars have many calendar_calendar_events
I have this Entity called 'Operation': @Entity @Table(name=operation) public class Operation implements Serializable {
Maybe this is a stupid question but it's bugging me. I have a bi-directional
Say I have a Customer - CustomerOrder one-to-many bi-directional relationship with the CustomerOrder holding
I have a User model which has many projects and a Project model which
I have a many to many relationship between nodes in a graph. All connections

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.