Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 758
  • Last Modified:

Nhibernate and SQL Server 2005

I'm using NHibernate with SQL Server 2005 and in my xml mappings file I have something like this :

 <id name="ID" type="long" column="logonID" access="property">
      <generator class="identity"/>

<b> Identity</b> is suppose to generate the ID and add to database. But everytime I get a SQL error saying can't add NULL to column logonID. What is I'm doing wrong ?

Please advise.
0
hthukral
Asked:
hthukral
  • 4
  • 3
1 Solution
 
GawaiCommented:
can i see the sturucture of your database ?
0
 
hthukralAuthor Commented:
I just have one table, its merely for testing with NHibernate.
0
 
GawaiCommented:
if you are trying to add ID of XML to the ID field of database (if it is autonumber). it will be the issue
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GawaiCommented:
i mean you cant insert into autonumber field
0
 
hthukralAuthor Commented:
Quote : if you are trying to add ID of XML to the ID field of database (if it is autonumber). it will be the issue

Sorry I'm confused. My field in databse is not auto-number. In that case how this problem can be resolved.
0
 
GawaiCommented:
make sure ID is in number or ID has any value before you insert
0
 
hthukralAuthor Commented:
That was fine, i just realised to use it as identity the primary key should have the identity set to true in database for every column and that fixed the problem.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now