0

In a SQL server db I have a Name column in the Departments table, with nvchar(25) not null, unique. I test to see what happens if I try and save a Department with a Name that is bigger than that and get an "NHibernate.Exceptions.GenericADOException" making it clear that ""String or binary data would be truncated". So far, so good.

In another table I have a Description column in a Projects table, with nvchar(50) not null, but doesn't have the unique constraint. I put it through the exact same test (of course making sure that the Description is bigger than 50), but no exception is thrown...

I prefer the very clear exception, but I'll settle for understanding what the rules are. Also how specific do NHib exceptions tend to be across different db's. What am I missing?

Cheers,
Berryl

ANSWER

My fault! I was using a test fixture that used SqlLite instead of SqlServer. This is one of the reasons I stopped using SqlLite in the first place (there must be a reason why so many smart people seem to love it, but it's useless for verifying nhibernate mapping IMO).

Thanks!

2 Answers 2

2

The behavior is controlled by the ANSI WARNINGS option:

if an INSERT or UPDATE is tried on a character, Unicode, or binary column in which the length of a new value exceeds the maximum size of the column

The option is a per database option.

0

Those errors are issued by MS SQL Server, not nHibernate. You should try running some queries directly using SQL Server Management Studio to determine what's going on.

1
  • Is there a particular query you have in mind to flesh this out?
    – Berryl
    Commented Jul 24, 2009 at 0:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.