HHH-9286 - Add CustomType implements ProcedureParameterNamedBinder
This commit is contained in:
parent
743ad3ef92
commit
50089b21dc
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.type;
|
package org.hibernate.type;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.sql.CallableStatement;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -39,7 +40,7 @@ import org.dom4j.Node;
|
||||||
*/
|
*/
|
||||||
public class CustomType
|
public class CustomType
|
||||||
extends AbstractType
|
extends AbstractType
|
||||||
implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType {
|
implements IdentifierType, DiscriminatorType, VersionType, BasicType, StringRepresentableType, ProcedureParameterNamedBinder {
|
||||||
|
|
||||||
private final UserType userType;
|
private final UserType userType;
|
||||||
private final String name;
|
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