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 6733499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:46:33+00:00 2026-05-26T10:46:33+00:00

I am trying to map a SQL Server database with nHibernate that is full

  • 0

I am trying to map a SQL Server database with nHibernate that is full of tables with varchar primary keys that are generated by external software and I need update/read (no insert) access.

I cannot find a way to get past the following error:

XXXX.Tests.GMCRepository_Fixture.Can_get_existing_GMC_by_parameter'
failed: NHibernate.MappingException :
XXXX.Domain.Mappings.GMC2.hbm.xml(4,6): XML validation 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, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-    mapping-2.2'.

Research has suggested this error is relating to there not being a valid primary key (id) defined.

Mapping XML looks like:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="XXXX.Domain" namespace="XXXX.Domain" xmlns="urn:nhibernate-mapping-2.2" schema="GM.dbo">
  <class name="GMC2" table="C2" lazy="true" >
    <property name="PARAMETER">
      <column name="PARAMETER" sql-type="varchar" not-null="true" />
    </property>
    ...
    <id name="Recid">
      <column name="recid" sql-type="varchar" not-null="true" />
    </id>
  </class>
</hibernate-mapping>

Thanks for your help!

  • 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-26T10:46:34+00:00Added an answer on May 26, 2026 at 10:46 am

    I believe that the convention is to have the ID mapping as the first thing under the class declaration.
    Also as part of the Id mapping you need to specify the Generator of the ID. In your case I think you will need the assigned generator added to your ID mapping. Your class mapping will look something like this.

    <?xml version="1.0" encoding="utf-8"?> 
    <hibernate-mapping assembly="XXXXCRMAPI.Domain" namespace="XXXXCRMAPI.Domain" xmlns="urn:nhibernate-mapping-2.2" schema="GoldMine.dbo"> 
      <class name="GMContact2" table="CONTACT2" lazy="true" > 
        <id name="Recid"> 
          <generator type="assigned" />
          <column name="recid" sql-type="varchar" not-null="true" /> 
        </id> 
        <property name="Accountno"> 
          <column name="ACCOUNTNO" sql-type="varchar" not-null="true" /> 
        </property> 
        ... 
    
      </class> 
    </hibernate-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to map a table frp, a SQL Server 2005 DB to
I'm trying to map a ManyToMany relationships between 2 tables, both having composite primary
I am trying to map several tables using Fluent Nhibernate. My tests are giving
I'm developing an application that reads data from a SQL server database (migrated from
I am trying to map a NHibernate formula for a nullable datetime field that
I'm trying to store images in a sql server database. I've got a column
I am using Nhibernate with SQL server 2008. I am trying to execute the
I am trying to map a legacy database here and I'm running into a
I'm trying to map a manyToMany relationship in Fluent NHibernate and running into a
I have a table with a time column in my SQL Server 2008 database.

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.