Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make setObject() throw a clear exception for TVP when using with result set #48

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()"},
};
}