Nhibernate应用-Text和Ntext数据类型的使用
2012-08-15 11:42
204 查看
今天用nhibernate的时候用户提交过来一个错误,说一个文本输入框输入字符过长,会被在固定的地方截断,经过试验发现4000个字符8000个字节的时候会被截断。看了一下映射文件中的xml配置,发现映射字段如下:
虽然该字段的长度被设置的足够大,但是使用过程中还是被截断了。查看了一下nhibernate的源码,发现在实际操作过程中发现nhibernate对string的处理时候自动将string类型按照数据中的nvarchar类型处理,最大长度4000字符,超过后自动截掉。查看了一下nhibernate 1.02的接口类型发现有一个StringClob,是处理长字符串的。
改变了xml里面的类型设置后,测试通过。
用fluent的配置更改
参考文献
http://www.primordialcode.com/blog/post/nhibernate-prepare_sql-considerations-mapping-long-string-fields
http://stackoverflow.com/questions/3701907/how-to-store-a-non-truncated-varcharmax-string-with-nhibernate-and-fluent-nhib
http://blog.csdn.net/sunearlier/article/details/1429178
<property column="InfoContent" type="String" name="InfoContent" length="2147483647" />
虽然该字段的长度被设置的足够大,但是使用过程中还是被截断了。查看了一下nhibernate的源码,发现在实际操作过程中发现nhibernate对string的处理时候自动将string类型按照数据中的nvarchar类型处理,最大长度4000字符,超过后自动截掉。查看了一下nhibernate 1.02的接口类型发现有一个StringClob,是处理长字符串的。
改变了xml里面的类型设置后,测试通过。
<property column="InfoContent" type="StringClob" name="InfoContent" length="2147483647" />
用fluent的配置更改
Map(x => x.Trafficintro).CustomType("StringClob").CustomSqlType("nvarchar(max)");
参考文献
http://www.primordialcode.com/blog/post/nhibernate-prepare_sql-considerations-mapping-long-string-fields
http://stackoverflow.com/questions/3701907/how-to-store-a-non-truncated-varcharmax-string-with-nhibernate-and-fluent-nhib
http://blog.csdn.net/sunearlier/article/details/1429178
相关文章推荐
- 不能比较或排序text、ntext和image数据类型,除非使用IS NULL 或 LIKE 运算符。
- Nhibernate应用-Text和Ntext数据类型的使用
- sql server数据类型char和nchar,varchar和nvarchar,text和ntext的区别
- sql server数据类型char和nchar,varchar和nvarchar,text和ntext的区别
- sqlserver数据类型char和nchar,varchar和nvarchar,text和ntext的用法以及区别
- ruby on rails 使用text存储hash类型的数据 Use text filed to store the hash map
- SQL中ntext、text 或 image 类型数据的处理
- sql server数据类型char和nchar,varchar和nvarchar,text和ntext的区别
- SQL数据库中数据类型ntext和text的区别
- SQL中数据类型char/varchar/nvarchar/nchar/text/ntext的区别
- 使用jquery、ajax不刷新页面打印表格(返回数据类型text、json);
- 转:邹建--对于局部变量,text、ntext 和 image 数据类型无效
- 对updatetext的使用(更新text,ntext类型的字段)
- sql server数据类型char和nchar,varchar和nvarchar,text和ntext的区别(转)
- SQL Server 2005 'Text,nText,image'数据类型被替代
- SQL Server 2005数据类型char,varchar,text ,nchar,nvarchar,ntext 等学习拾遗
- sql server数据类型char和nchar,varchar和nvarchar,text和ntext
- 求解一个设计到ntext text image的数据类型触发器
- SQL数据库中数据类型ntext和text的区别
- GROUP BY 不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。