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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:28:22+00:00 2026-05-23T13:28:22+00:00

I try to use this tutorial: Hello NHibernate This is my config NHibernate file:

  • 0

I try to use this tutorial: Hello NHibernate

This is my config NHibernate file:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <reflection-optimizer use="false"/>
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=.\SQLEXPRESS; Initial Catalog=dbTest; Trusted_Connection=true;</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="show_sql">true</property>
      <mapping resource="TestNHibernate.user.hbm.xml" assembly="TestNHibernate"/>
    </session-factory>
  </hibernate-configuration></configuration>

This is my mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                           assembly="TestNHibernate"
                           namespace="TestNHibernate">
  <class name="user" table="user">
    <id name="Id">
      <generator class="identity"/>
    </id>
    <property name="Name"  />
  </class>
</hibernate-mapping>

Class user:

 class user
    {

        public virtual int Id { get;set; }
        public virtual string Name { get; set; }
    }

and here is query code:

 Configuration config = new Configuration();
                config.AddAssembly(typeof(user).Assembly);
                ISessionFactory sessionFactory = config.BuildSessionFactory();

                using (var session = sessionFactory.OpenSession())
                {                   
                    IQuery query = session.CreateQuery("from user as u");
                    IList<user> lst = query.List<user>();
                    foreach (var user in lst)
                    {
                        Console.WriteLine(user.Name);
                    }
                }

It’s always show error:

could not execute query [ select
user0_.Id as Id0_, user0_.Name as
Name0_ from user user0_ ] [SQL: select
user0_.Id as Id0_, user0_.Name as
Name0_ from user user0_]

I tried to insert, update but it’s also show could not insert, update. Where is my problem?

Is there my mapping file?
Please give me advice! Thanks!

  • 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-23T13:28:22+00:00Added an answer on May 23, 2026 at 1:28 pm

    Two things:

    (1) In your mapping file, you should be enclosing the User table in square brackets, e.g. [User]. User is a reserved keyword in SQL Server (and most other SQL systems).

    <class name="user" table="[user]">
    

    (2) Whenever you get an exception in NHibernate, go into debug mode and look at the inner exceptions. Those usually provide hints as to what the problem is.

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

Sidebar

Related Questions

I try to use this mapping : @Entity @Table(name=ecc.\RATE\) @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name=DISCRIMINATOR, discriminatorType= DiscriminatorType.STRING) public
Hi i try use Nlog in with caliburn micro, I have use this tutorial
When I try to use this in my Javascript prototype like so: Array.prototype.sample =
I try to update my profile image and use this code: $connection->post('account/update_profile_image', array('image' =>
I get this error when I try to use time_ago_in_words : Comparison of String
I try to use the boolean in my class and get this message reference
i am having this problem try to use the cocos2d CCScrollLayer I have added
I have this implementation with fusion table layers where I try to use the
Try to download this page: http://www.4shared.com/get/B4AgMkcw/cookies.html I can use wget/firefox to get the whole
This article on MSDN states that you can use as many try catch blocks

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.