There will also be problems with nhib.pdf, but it's better to find the cause.

Source: Internet
Author: User
After a long time, I started learning about nhib.pdf. After a long time, I encountered some problems and recorded them,

1. An error is prompted for nhib.pdf
The dialect was not set. Set the property hibernate. dialect.
Solution:
Because I used two project files, one of which is a class library project and the other is a web project, I will use the following section in nhib.pdf. cfg. XML is put in the class library project. In fact, we need to put this section on the web. config file.
<? XML version = "1.0" encoding = "UTF-8" ?>
< Hibernate-Mapping Xmlns = "Urn: nhibernate-mapping-2.0" >
< Class Name = "PB. testdal. DB. Users, testdal1" Table = "Users" >
< Logonid Name = "Logonid" Column = "Logonid" Type = "String (20 )" >
< Generator Class = "Assigned"   />
</ Logonid >
< Property Name = "Name" Type = "String" Column = "Name (40 )" />
< Property Name = "Password" Type = "String" Column = "Password (20 )" />
< Property Name = "Emailaddress" Type = "String" Column = "Emailaddress (20 )" />
< Property Name = "Lastlogon" Type = "Datetime" Column = "Lastlogon"   />
</ Class >
</ Hibernate-Mapping >
2. An error is prompted for nhib.pdf
Identiifier of an instance of dataaccess. User altered from 13 (system. int16) to 13 (system. int32
Solution:
Because the int length of SQL Server 2000 is set to 4, the int16 type is int32.
<? XML version = "1.0" encoding = "UTF-8" ?>
< Hibernate-Mapping Xmlns = "Urn: nhibernate-mapping-2.0" >
< Class Name = "PB. testdal. DB. Users, testdal1" Table = "Users" >
< Logonid Name = "Logonid" Column = "Logonid" Type = "Int16" >
< Generator Class = "Assigned"   />
</ Logonid >

< Property Name = "Name" Type = "String" Column = "Name (40 )" />
< Property Name = "Password" Type = "String" Column = "Password (20 )" />
< Property Name = "Emailaddress" Type = "String" Column = "Emailaddress (20 )" />
< Property Name = "Lastlogon" Type = "Datetime" Column = "Lastlogon"   />
</ Class >
</ Hibernate-Mapping >
3. An error is prompted for nhib.pdf
Invalid Column
Solution:
View the HBM. xml ing file, Whether column = "name"/> corresponds to the column name in the database

There are three key points to note when writing a ing file.
<? XML version = "1.0" encoding = "UTF-8" ?>
< Hibernate-Mapping Xmlns = "Urn: nhibernate-mapping-2.0" >
< Class Name = "PB. testdal. DB. Users, testdal1" Table = "Users" >
< Logonid Name = "Logonid" Column = "Logonid" Type = "String (20 )" >
< Generator Class = "Assigned"   />
</ Logonid >

< Property Name = "Name" Type = "String" Column = "Name (40 )" />
< Property Name = "Password" Type = "String" Column = "Password (20 )" />
< Property Name = "Emailaddress" Type = "String" Column = "Emailaddress (20 )" />
< Property Name = "Lastlogon" Type = "Datetime" Column = "Lastlogon"   />
</ Class >
</ Hibernate-Mapping >
1. Dataaccess. User,,Whether the namespace corresponding to the class is consistent, and the case must also be consistent
2. Type = "string (25,Is the field length defined in this way?
3. Column = "password,Whether the column names are consistent with the fields in the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.