HHH-9286 - Add CustomType implements ProcedureParameterNamedBinder
This commit is contained in:
parent
9567d9af76
commit
a339ebd8a9
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -39,7 +40,7 @@ import org.dom4j.Node;
|
|||
*/
|
||||
public class CustomType
|
||||
extends AbstractType
|
||||
implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType {
|
||||
implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType, ProcedureParameterNamedBinder {
|
||||
|
||||
private final UserType userType;
|
||||
private final String name;
|
||||
|
@ -250,4 +251,25 @@ public class CustomType
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDoSetting() {
|
||||
if ( ProcedureParameterNamedBinder.class.isInstance( userType ) ) {
|
||||
return ((ProcedureParameterNamedBinder) userType).canDoSetting();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullSafeSet(
|
||||
CallableStatement statement, Object value, String name, SessionImplementor session) throws SQLException {
|
||||
if ( canDoSetting() ) {
|
||||
((ProcedureParameterNamedBinder) userType).nullSafeSet( statement, value, name, session );
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException(
|
||||
"Type [" + userType + "] does support parameter binding by name"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue