The following are some of the minor problems I encountered while using nhib.pdf. Record them and use them as notes!
1. Auto-incrementing sequence and strict type Matching
HBM. the generator class in the XML configuration file can be set to "increment" or "sequence", it is best to use "increment", using "sequence" sometimes throws the "ORA-02289: sequence (number) does not exist "exception!
In addition, when loading an object, the type of the input ID must be exactly the same as that of the database. For example, the auto-incrementing primary key is as follows:
<ID name = "ID" type = "int64">
<Column name = "ID" SQL-type = "Number" not-null = "true" unique = "true" Index = "idpk"/>
<Generator class = "sequence"/>
</ID>
When the following statement is used, an exception is thrown -- "identifier Type Mismatch \ r \ n Parameter Name: ID ":
Verduemessage nmsg = (overduemessage) Session. Load (typeof (overduemessage), 2 );
But if it is like the following, it will be OK:
Long id = 2;
Overduemessage nmsg = (overduemessage) Session. Load (typeof (overduemessage), ID );
2. If the auto-increment primary key of the Oracle database is used, the isession. Save () method returns the primary key value.
3. Oracle Auto-incrementing sequence Creation
(1) create a sequence seq_test
(2) create a trigger on the target field
Begin
Select xtgl. seq_test.nextval into: New. ID from dual;
End;
4. No size set for variable length data type: String
Cause: in Oracle, a string of 0 length (that is, "") cannot be inserted. The value of this parameter must be set to null (if it is datarow, set the corresponding field to system. dbnull. value, such as newrow [0] = system. dbnull. value;), the problem is solved.
5. Case sensitivity
When creating a table in Oracle, the table name and all column names are converted to uppercase. When accessing a table in Oracle, the table name in the SQL statement must be in uppercase, while the column name can be ignored.