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