hibernate 操作Geometry类型为null时返回The TDS protocol does not support JDBC datatype 2002,解决方法如下:

引用自http://sourceforge.net/p/jtds/discussion/104388/thread/5d7d1dad/?limit=25

I found that the JDBC datatype "2002" corresponds to a java.sql.Types.STRUCT

The TdsData.getNativeType(JtdsConnection connection, ParamInfo pi) does not support type STRUCT.

JtdsPreparedStatement method setNull sets the jdbcType, based on the sqlType sent from Hibernate spatial.

In JtdsPreparedStatement.setNull (line 852), I found that both CLOB and BLOB had special cases for setting the value to null. I replicated that code for setting type STRUCT to null.

if (sqlType == java.sql.Types.CLOB) { sqlType = java.sql.Types.LONGVARCHAR; } else if (sqlType == java.sql.Types.BLOB) { sqlType = java.sql.Types.LONGVARBINARY; } else if (sqlType == java.sql.Types.STRUCT) { sqlType = java.sql.Types.LONGVARBINARY; }

This fixes the issue I found, but I don't know if there are other unintended consequences.

Is this the appropriate place for a fix? Or should I update TdsData.getNativeType


Comments

comments powered by Disqus