Notes for Castle activerecord access to Oracle

Source: Internet
Author: User
I used to use AR to access SQL Server and work well. recently, I switched my database to Oracle 8i. I encountered several minor problems when using AR for access. Now I want to provide the Problem description and solution, and hope to provide some help to my friends who encountered the same problem.

[1] primary key ing attributes:
Set sequence or native instead of identity.
Example: (the ID type in the table is number) [Primarykey (primarykeytype. sequence, " ID " )]
Public   Int ID
{
Get { Return   This . ID ;}
Set { This . ID = Value ;}
}

[2] varchar2 type ing:
When ing the string type to the varchar2 type in the table, you need to indicate the aning to ansistring in the ing property when ing, otherwise the exception will be reported once the update operation is involved: "ORA-12704: character Set mismatch ".
Example: (the name type in the table is varchar2)[Property ( " XM " , Columntype =   " Ansistring " )]
Public   String Name
{
Get { Return   This . Name ;}
Set { This . Name = Value ;}
}

[3] execute hql statement Report "ORA-12704: Character Set mismatch" exception:
Although you have set the aning to ansistring in step [2], this exception will still be reported during hql query (simplequery) execution.
Later, we found that this exception would occur as long as simplequery in the form of passing parameters, but there is no problem in the form of literal strings. Therefore, the solution is to use the ugly string connection method,
Example: (an exception is reported when the line commented out is executed) Public   Static Tuser findbyname ( String _ Name)
{
Simplequery =   New Simplequery ( Typeof (Tuser ), @" From Tuser user where user. Name =' "   + _ Name +   " ' " );
// Simplequery query = new simplequery (typeof (Tuser), @ "from Tuser user where user. Name =? ", _ Name );
Return (Tuser []) (executequery (query )))[ 0 ];
}

Finally:
As I am only working on a small system, there must be some other problems I have not found, so many problems I have found for the moment.
At the same time, I have been wondering if my Oracle 8i character set is not set properly? Or why? (I am using Oracle dishes...) Please kindly advise me ~~

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.