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.

Sign up to request clarification or add additional context in comments.

Comments

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 Comment

Is there a particular query you have in mind to flesh this out?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.