tags:

views:

26

answers:

0

Hi, I'm using VS 2008, ASP.NET MVC with NHibernate 2.0. I get the following error of row not found when I retrieve collection of objects from 2 manyTomany tables. Here what is the "Identifier" 296 refers to? Is that the same as Application object with "Id" = 296? I search the manyTomany index table, ApplicationResearchInterests, and found no applicationId that equals to 296. Where is this coming from? Thank you.

  • result Count = 21 System.Collections.Generic.IList {System.Collections.Generic.List}
  • [0] {CtsiSearchMembership.Models.ResearchInterest} CtsiSearchMembership.Models.ResearchInterest
  • applications {NHibernate.Collection.Generic.PersistentGenericBag} System.Collections.Generic.IList {NHibernate.Collection.Generic.PersistentGenericBag} Id 2 long Name "Anatomical Systems or Sites" string
  • ParentResearchInterest {CtsiSearchMembership.Models.ResearchInterest} CtsiSearchMembership.Models.ResearchInterest
  • [1] {CtsiSearchMembership.Models.ResearchInterest} CtsiSearchMembership.Models.ResearchInterest
  • applications {NHibernate.Collection.Generic.PersistentGenericBag} System.Collections.Generic.IList {NHibernate.Collection.Generic.PersistentGenericBag}
  • base {"No row with the given identifier exists[CtsiSearchMembership.Models.Application#296]"} NHibernate.UnresolvableObjectException {NHibernate.ObjectNotFoundException}
  • base {"No row with the given identifier exists[CtsiSearchMembership.Models.Application#296]"} NHibernate.HibernateException {NHibernate.ObjectNotFoundException} EntityName "CtsiSearchMembership.Models.Application" string Identifier 296 object {long} Message "No row with the given identifier exists[CtsiSearchMembership.Models.Application#296]" string
  • PersistentClass null System.Type
  • Non-Public members
  • Raw View Id 33 long Name "Biomedical Engineering" string
  • ParentResearchInterest {CtsiSearchMembership.Models.ResearchInterest} CtsiSearchMembership.Models.ResearchInterest

Here are the 2 mappings for my 2 manyTomany tables:

using CtsiSearchMembership.Models;
using FluentNHibernate.Mapping;

namespace CtsiSearchMembership.ModelMapping
{
  public class ApplicationMap: ClassMap<Application>
  {
    public ApplicationMap()
    {
      WithTable("Applications");
      Id(x => x.Id);
      Map(x => x.FirstName);
      Map(x => x.LastName);
      Map(x => x.EmailAddress);
      Map(x => x.PhoneNumber);
      Map(x => x.MailingAddressLine1);
      Map(x => x.MailingAddressLine2);
      Map(x => x.MailingAddressCity);
      Map(x => x.MailingAddressState);
      Map(x => x.MailingAddressZip);
      Map(x => x.Institution);
      Map(x => x.InstitutionOther);
      Map(x => x.CommunityOrganization);
      References(x => x.Title);
      Map(x => x.TitleOther);
      Map(x => x.Department);
      Map(x => x.ProfessionalOrganizations);
      Map(x => x.MembershipLevel);
      Map(x => x.MembershipReasonOther);
      Map(x => x.PhdTraineeCount);
      Map(x => x.MscTraineeCount);
      Map(x => x.Gender);
      Map(x => x.YearOfBirth);
      Map(x => x.Race);
      Map(x => x.RaceOther);
      Map(x => x.Ethnicity);

      //Many to Many mappings
      //HasManyToMany<ResearchInterest>(x => x.ResearchInterests).Cascade.All().WithTableName(
      // "ApplicationResearchInterests");
      HasManyToMany<ResearchInterest>(x => x.ResearchInterests).AsBag().Not.LazyLoad().NotFound.Ignore().WithTableName(
  "ApplicationResearchInterests")
        .WithParentKeyColumn("ApplicationId").WithChildKeyColumn(
"ResearchInterestId");
      HasManyToMany<Degree>(x => x.Degrees).AsBag().WithTableName("ApplicationDegrees").WithParentKeyColumn(
"ApplicationId").WithChildKeyColumn("DegreeId");
      HasManyToMany<MembershipReason>(x => x.MembershipReasons).AsBag().WithTableName(
"ApplicationMembershipReasons").WithParentKeyColumn("ApplicationId").WithChildKeyColumn(
"MembershipReasonId");
      HasManyToMany<MembershipServiceRequirement>(x => x.MembershipServiceRequirements).AsBag().WithTableName(
"ApplicationMembershipServiceRequirements").WithParentKeyColumn("ApplicationId").WithChildKeyColumn(
"MembershipServiceRequirementId");
    }
  }
}

using FluentNHibernate.Mapping;
using CtsiSearchMembership.Models;

namespace CtsiSearchMembership.ModelMapping
{
  public class ResearchInterestMap : ClassMap<ResearchInterest>
  {
    public ResearchInterestMap()
    {
      WithTable("ResearchInterests");
      Id(x => x.Id);
      Map(x => x.Name);
      References(x => x.ParentResearchInterest);
      //HasManyToMany<Application>(x => x.applications).Cascade.All().Inverse().WithTableName(
      // "ApplicationResearchInterests");
HasManyToMany<Application>(x => x.applications).AsBag().WithTableName(
"ApplicationResearchInterests").WithParentKeyColumn("ApplicationId").WithChildKeyColumn(
"ResearchInterestId");
    }
  }
}