NHibernate 对象映射 - Mysql text mediumtext longtext

NHibernate 版本 - 2.1.2.4000 GA

(原文链接 http://ddbiz.com/?p=147)

mysql 的text类型有三个:

Text 可以存储64KB数据,即 char 65535 

MediumText 可以存储16MB数据,即 char 16777216

LongText 可以存储4GB数据,  即 char 4294967296 

 

针对NH的映射,可以分别写为:

Text:

<property name="Content" type="String(65535)" column="Content" lazy="true" />

 

MediumText:

<property name="Content" type="String(16777216)" column="Content" lazy="true" />

 

LongText:

没有找到呢,谁补充下

 

 

普通String的映射,不可以超过 255,否则就成为 Text 了

<property name="Content" type="String(255)" column="Content" lazy="true" />

 

补充:

不过在 NH2.x 以后,如下的映射会得到你想要的大小:

<property name="Content" type="String(1024)" column="Content"  />

 

mysql -> desc table:

Content         | varchar(1024) | YES  |     | NULL    |                |

(原文链接 http://ddbiz.com/?p=147)

你可能感兴趣的:(NHibernate 对象映射 - Mysql text mediumtext longtext)