Orchard 1.6 - NHibernate 3.3 - String length problem

Topics: Troubleshooting
Nov 7, 2012 at 9:14 AM

Hi,

I've upgraded to Orchard 1.6 on a website which is dealing with large contents. It seems that NHibernate 3.3 impose a string length constraint even if columns are configured as below :

this.SchemaBuilder.CreateTable( "MyPart", t => t .ContentPartRecord() .Column("Col1", DbType.String, a => a.Unlimited()) .Column("Col2", DbType.String, a => a.Unlimited()) );

The error message is : NHibernate.HibernateException: The length of the string value exceeds the length configured in the mapping/parameter.

I've found few articles like this one : http://geekswithblogs.net/lszk/archive/2011/07/11/nhibernatemapping-a-string-field-as-nvarcharmax-in-sql-server-using.aspx which is highlighting the problem.

Is there a way to pass through this limitation ?

Thanks

Nov 7, 2012 at 9:55 AM
Edited Nov 7, 2012 at 9:56 AM

If this is indeed the case, you should report a bug and do include what DB backend/server you use.

Also, check the table @ db to see what size limit it was given there.

Nov 8, 2012 at 1:24 PM
Edited Nov 8, 2012 at 1:24 PM

Thanks for you answer. I've found a solution : adding [StringLengthMax] attribute on ContentPartRecord attributes then uninstall and republish my module. But I don't think it is the expected behavior of the application ...

@dinsx

Nov 8, 2012 at 2:01 PM

Hmm, is it now required to have those attributes? (I never added them since I always custom-design the table changes)

Could someone clarify this?

Nov 16, 2012 at 1:59 AM

I've always been required to include this attribute for large strings.  However, the problem would only arise when the string actually exceeded a certain size.  I believe it's 4000 characters.  

Aug 20, 2013 at 4:03 PM
How do I use the attribute? My model classes don't recognize them, only [StringLength]. What class/namespace do I need to import in order to use [StringLengthMax]?
Developer
Aug 20, 2013 at 4:08 PM
Edited Aug 20, 2013 at 4:09 PM
Orchard.Data.Conventions.StringLengthMaxAttribute. Ctrl+F (or Ctrl+T if you use R#) is your friend...
Developer
Aug 20, 2013 at 4:14 PM
AimOrchard wrote:
Hmm, is it now required to have those attributes? (I never added them since I always custom-design the table changes) Could someone clarify this?
As Brandon already mentioned - it was always required.