-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: The element 'class' in namespace 'urn:nhibernate-mapping-2.2
PostPosted: Thu Jun 03, 2010 8:41 pm 
Newbie

Joined: Thu Jun 03, 2010 8:30 pm
Posts: 4
Hi, I'm using ASP.NET MVC, C#, NHibernate v2.0.50727 and FluentNHibernate. I have 2 tables that has one to many relationship. I want to do a select query by joining them but I am getting the following error:
The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'meta, jcs-cache, cache, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.

After searching the internet, it seems one of the posting says that I need to declare an ID in table mapping. The problem is that one of the table doesn't have a primary key as id field. The Application Field has a primary key and the ApplicationResearchInterests table servers as a middle table for manyToMany relationship between Application table and the ReserachInterests table so it only contains 2 foreign keys for mapping these 2 tables. Below is my class map and the query that's giving me the error message. I appreciate any help here.

public IList<Application> FindMembersByInterestIds(string ids)
{
var query = "select distinct a from Applications a" +
" join ApplicationResearchInterests ar on a.Id = ar.ApplicationId" +
//" where ar.ResearchInterestId in('2', '574', '110', '1111', '1123')";
" where ar.ResearchInterestId in( " + ids + ")";
IList<Application> applications = Database.Session.CreateQuery(query).List<Application>();

return applications;
}

using CtsiSearchMembership.Models;
using FluentNHibernate.Mapping;

namespace CtsiSearchMembership.ModelMapping
{
public class ApplicationResearchInterestsMap : ClassMap<ApplicationResearchInterests>
{
public ApplicationResearchInterestsMap()
{
WithTable("ApplicationResearchInterests");
Map(x => x.ApplicationId);
Map(x => x.ResearchInterestId);
}
}
}


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).AsBag().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");
}
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.