2012-03-23 71 views
2

这里是我的问题:我有Oracle数据库10g,我使用nhibernete 2.1进行映射。现在,当我在Oracle中创建一个表我的表的hbm.xml文件中是这样使用nhibernate的Oracle NVARCHAR2(Max)2.1

<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="AssembleName" namespace="NamesapceName" > 
<class name="ClassName" table="TableName" schema="ScheamName" 
    dynamic-update="true" dynamic-insert="true" select-before-update="true"> 
<id name="Id" column="id" type="integer" unsaved-value="0"> 
    <generator class="native"></generator> 
</id> 
<property name="Name" column="name" type="StringClob" length="100000" not-null="true" /> 
    </class> 

,如果我给的属性大于4000的长度可以此格式创建

create table TableName (
    id NUMBER(10,0) not null, 
    name NCLOB not null, 
    primary key (id) 
) 

当我使用我自己的函数获取表项时
我遇到Oracle.DataAccess.Client.OracleException:ORA-00932:不一致的数据类型:预计 - 得到NCLOB问题 但是当我设置属性像

<property name="Name" column="name" type="string" length="2000" not-null="true" /> 

它采用该格式

create table TableName (
    id NUMBER(10,0) not null, 
    name NVARCHAR(2000) not null, 
    primary key (id) 
) 

创建和我用于读取数据的功能是工作的罚款。但我需要一个字符串长度大于4000且没有Oracle.DataAccess.Client.OracleException的表:ORA-00932:不一致的数据类型:预计 - 得到NCLOB

+3

在Oracle中,您无法定义超过4000个字节的(N)VARCHAR列。您必须使用CLOB或NCLOB才能获得更大的值。请向我们展示访问该列的“* own function *”的代码。 – 2012-03-23 07:55:22

回答

1

你试过这个吗?

<property name="Name" length="10000" not-null="true" /> 

我使用的是SQL Server和我不需要在这种情况下,指定一个类型。