NHibernate 3.3 中如何存储长于4000字符的字符串

在NHibernate 3.3 中存储的字符串太长,会抛异常:The length of the string value exceeds the length configured in the mapping/parameter.

有人会说这是新版NHibernate的一个Bug,3.2就不会出现这样的情况。实际上,对于string类型的属性值,NHibernate默认值最大值是4000个字符,在3.2中会自动截断,在3.3中会给你抛一个异常出来,所以这并不是一个Bug,如果你想存储超过4000个字符的字符串,请在映射文件中修改该属性的类型,使用 type="StringClob" 

<property name="myProp" column="MY_PROP" not-null="true" type="StringClob" access="property"></property>  

  

参考:第一个是NHibernate在JIRA任务管理系统上的一个Bug报告,如果你发现什么NHibernate的Bug,可以登录该系统创建一个Bug任务,就会有专业人员来验证修复。

https://nhibernate.jira.com/browse/NH-3130

http://stackoverflow.com/questions/12708171/the-length-of-the-string-value-exceeds-the-length-configured-in-the-mapping-para

原文地址:https://www.cnblogs.com/young2012/p/2842213.html