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

  • Home
  • SEARCH
  • 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 3212832
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:52:45+00:00 2026-05-17T14:52:45+00:00

I hope anyone can help. I have to develop up against this third party

  • 0

I hope anyone can help. I have to develop up against this third party database and I am kind of stuck with their crappy design. Still, I want to use NHibernate so I will have to jump through hoops.

Simplified, there is this “Event” table that has a relation a “Transportation” table. The transportation table has a composite primary key composed of the field “ID” and “FK_EventID”, the latter of course referring back to the Event-record. Each event points to one distinct record in the transportation table, so it is a one-to-one relation really. Both fields are Guids BTW.

Attempting to map this out, this is how I created the classes (leaving out other data fields for simplicity’s sake):

   public class FcoEvent : IFcoObject
   {
       public virtual Guid ID { get; set; }

       //public virtual Guid FK_TransportationID { get; set; } //ignore
       public virtual FcoTransportation Transportation { get; set; } 

And:

[Serializable]
public class FcoTransportation : IFcoObject
{
    #region Members

    public virtual Guid ID { get; set; }

    public virtual Guid FK_EventID { get; set; }

In the mapping files I am attempting this (note that I am using many-to-one):

   <class name="FcoLib.FcoEvent, FcoLib" table="FCO_Event">
     <id name="ID" column="ID">
      <generator class="guid" />
     </id>
     <many-to-one name="Transportation" not-found="ignore" cascade="save-update"
                 class="FcoLib.FcoTransportation, FcoLib">
     <column name="FK_TransportationID" />
     <column name="ID" />
    </many-to-one> 

And:

   <class name="FcoLib.FcoTransportation, FcoLib" table="FCO_Transportation">
     <composite-id>
       <key-property name="ID" />
       <key-property name="FK_EventID" />
     </composite-id>

When I try to run this, I get the following exception message:

NHibernate.QueryException: could not resolve property: FK_TransportationID of: FcoLib.FcoEvent

My first hunch was that there may be a spelling error in the field name, but that didn’t hold. So now I am completely puzzled and don’t know how to proceed. Any help is greatly appreciated. Thnx.


Update

I think I found the source of the error. I had not looked there yet, because I assumed it was a mapping error, but apparently it is a querying error. It happens where I do the query:

fcoEvents = session.CreateCriteria(typeof(FcoEvent))
                    .Add(Restrictions.Eq("ID", eventId))
                    .Add(Restrictions.Eq("FK_TransportationID", transportId))
                    .List<FcoEvent>();

I will look further into this, but obviously I need to query this in a different way…

  • 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-17T14:52:45+00:00Added an answer on May 17, 2026 at 2:52 pm

    Silly me. I have been distracted by some faulty, outdated code. The point was to be able to retrieve the event including the related transport child using the primary key of the event and that simply works. Also it should be possible to retrieve the transport issue with the composite primary key and that can be accomplished with the below code.

        public FcoTransportation GetTransportation(Guid transportId, Guid eventId)
        {
            FcoTransportation transport;
    
            ISession session = Factory.OpenSession();
            ITransaction tx = session.BeginTransaction();
            try
            {
                transport = session.Get<FcoTransportation>(new FcoTransportation()
                   {
                       ID = transportId,
                       FK_EventID = eventId
                   });
    

    So this has been a non-issue really. I have just been confused by the whole composite foreign key stuff. I hope I did not waste people’s time.

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

Sidebar

Related Questions

Really hope someone can help me as I'm a bit stuck :S I have
Hope anyone can shed light on this so I can use pens with dash
I hope there's a SharePoint expert here on SO who can help with this.
Hi guys I hope anyone can help me. I'm running a simple program in
I hope anyone from the large community here can help me write the simplest
Hello Fellow Computer People! Anyone willing to help will have my gratitude ;) Just
I hope this question does not come off as broad as it may seem
I hope everyone will pardon the length, and narrative fashion, of this question. I
I hope this question is not considered too basic for this forum, but we'll
I hope this is programmer-related question. I'm in the hobby business of C# programming.

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.