We are getting DataTruncation errors writing a 51 character Java string to an nvarchar(100). A 50 character string works fine.
We used a custom dialect to ensure that the column is an nvarchar, and the XDoclet tag is as follows:
Code:
* @hibernate.property
* column="Name"
* length="100"
* not-null="false"
Code:
public class UnicodeSQLServerDialect extends SQLServerDialect {
public UnicodeSQLServerDialect() {
registerColumnType( Types.CHAR, "nchar(1)" );
registerColumnType( Types.VARCHAR, "nvarchar($l)" );
registerColumnType( Types.CLOB, "ntext" );
}
}
I have verified that the column is in fact nvarchar(100).
Any ideas for troubleshooting this? We are on Hibernate 3.1 and SQLServer.2005, the driver is jtds: 1.2.
Thanks,
Richard