Skip to content

Commit

Permalink
Merge pull request #48 from v-xiangs/tvp_setObject_resultset
Browse files Browse the repository at this point in the history
make setObject() throw a clear exception for TVP when using with result set
  • Loading branch information
xiangyushawn authored Dec 1, 2016
2 parents ab97db4 + 42b6547 commit 7d8d3e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1474,9 +1474,16 @@ final void setObjectNoType(int index, Object obj, boolean forceEncrypt) throws S
else
{
JavaType javaType = JavaType.of(obj);
if (JavaType.TVP == javaType)
if (JavaType.TVP == javaType){
tvpName = getTVPNameIfNull (index, null); //will return null if called from preparedStatement
targetJDBCType = javaType.getJDBCType(SSType.UNKNOWN, targetJDBCType);

if((null == tvpName) && (obj instanceof ResultSet)){
throw new SQLServerException(
SQLServerException.getErrString("R_TVPnotWorkWithSetObjectResultSet"),
null);
}
}
targetJDBCType = javaType.getJDBCType(SSType.UNKNOWN, targetJDBCType);

if(JDBCType.UNKNOWN == targetJDBCType){
if(obj instanceof java.util.UUID){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ protected Object[][] getContents()
{"R_invalidCEKCacheTtl", "Invalid column encryption key cache time-to-live specified. The columnEncryptionKeyCacheTtl value cannot be negative and timeUnit can only be DAYS, HOURS, MINUTES or SECONDS."},
{"R_sendTimeAsDateTimeForAE", "Use sendTimeAsDateTime=false with Always Encrypted."},
{"R_invalidServerCursorForTVP" , "Use different Connection for source ResultSet and prepared query, if selectMethod is set to cursor for Table-Valued Parameter."},

{"R_TVPnotWorkWithSetObjectResultSet" , "setObject() with ResultSet is not supported for Table-Valued Parameter. Please use setStructured()"},
};
}

0 comments on commit 7d8d3e5

Please sign in to comment.