Skip to content

Commit

Permalink
make setObject() throw a clear exception for TVP when using with resu…
Browse files Browse the repository at this point in the history
…lt set
  • Loading branch information
xiangyushawn committed Dec 1, 2016
1 parent a23e8b2 commit 42b6547
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 @@ -1461,9 +1461,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 42b6547

Please sign in to comment.