Nhib.pdf and Oracle

Source: Internet
Author: User

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.
 

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.