1. Batch update returned unexpected row count from Update [0]; actual row count: 0; expected: 1
Batch update returned unexpected row count from Update [0]; actual row count: 0; expected: 1 this exception occurs because the primary key is set to auto-increment, this is caused by setting the id value when inserting records. In the ing file, set <ID name = "ID" column = "ID" type = "integer"> <generator class = "increment"/> </ID>, the id value is set when data is inserted.
If the trigger is used, the following errors occur:
Solution:
Add the following statement to the trigger script -- start point (before the AS and begin)
Set nocount on; End (after end)
Set nocount off
Cause Analysis: When nhib.pdf performs a change operation on the database, it compares the number of change records with the actual number of affected records returned by the database (that is, the return value of @ rowcount ), if the two are inconsistent, the above exception is thrown. The reason for changing the actual number of affected records returned by the database is that the update, insert, or delete statements are executed in the trigger. WhileThe nocount switch is used to prevent SQL Server from returning the number of affected records after performing the data change operation.. As long as the nocount switch is enabled before the Database Change operation is executed in the trigger script, nhib.pdf can get the expected results and eliminate this exception.
2.net. SF. hibernate. propertyaccessexception: exception setting property value with cglib setter of COM. Your. entity. classname. Set ***()
It is also a common error. There are many causes of this error, such as type conversion errors and nullpoinerexcption.
Here we will talk about nullpointerexception. hibernate has a problem. For fields whose Java type is basic type, if this field in the database is null, nullpointerexception will be triggered when loading data, resulting in propertyaccessexception.
3. No row with the given identifier exists in Nhibernate
Cause:
There are two tables, table1 and table2. are associated with <one-to-one> or <allow-to-one unique = "true"> (Special multiple-to-one ing, actually, it is one-to-one) to associate table2. when hibernate searches, no data in Table2 matches Table1, and the error no row with the given identifier exists will be reported. (In a word, it is a data problem !)
Assume that table 1 has its own primary key id1 and table 2's primary key Id2.
If the single-item association set by Nhibernate, even if Id2 in Table1 is null and Id2 in Table2 has a value, no query error will occur. however, if the Id2 field in Table 1 has a value but this value does not exist in the primary key value in table 2, the above error will be reported!
If Nhibernate is a bidirectional Association, Id2 in Table1 is null, but if there is a value in Table2, this error is reported. in this case, the current solution is to change to a single association, or change the corresponding data!