[hibernate-dev] SqlTypeDescriptor bind by name limitation
Steve Ebersole
steve at hibernate.org
Wed Jun 7 11:39:18 EDT 2017
Ignoring some poor wording in the Javadocs by me :)
On Wed, Jun 7, 2017 at 10:38 AM Steve Ebersole <steve at hibernate.org> wrote:
> I'm not sure what you mean when you say that SqlTypeDescriptor only
> supports binding by name. On both 5.2 and 6.0 I see :
>
> /**
> * Bind a value to a prepared statement.
> *
> * @param st The prepared statement to which to bind the value.
> * @param value The value to bind.
> * @param index The position at which to bind the value within the prepared statement
> * @param options The options.
> *
> * @throws SQLException Indicates a JDBC error occurred.
> */
> public void bind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException;
>
> /**
> * Bind a value to a CallableStatement.
> *
> * @param st The prepared statement to which to bind the value.
> * @param value The value to bind.
> * @param name The name to bind the value within the prepared statement
> * @param options The options.
> *
> * @throws SQLException Indicates a JDBC error occurred.
> */
> public void bind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException;
>
>
>
> Which is what you'd expect. I'm not really following what you are
> saying. A CallableStatement is also a PreparedStatement so we already know
> how to bind positionally against both PreparedStatement (and
> CallableStatement, since they are PreparedStatement). And only for
> CallableStatement does JDBC define additional support for binding by name.
>
> And 6.0 is going to bind by position, but that's what all other versions
> of Hibernate have done. The change in 6.0 you are thinking about is
> *reading* values back (from ResultSets, CallableStatement params, etc).
>
> On Wed, Jun 7, 2017 at 9:13 AM Vlad Mihalcea <mihalcea.vlad at gmail.com>
> wrote:
>
>> Hi,
>>
>> While writing an example for a custom Hibernate Type which supports
>> PostgreSQL arrays,
>> I realized that the SqlTypeDescriptor only supports bind by name:
>>
>> @Override
>> protected void doBind(CallableStatement st, X value, String name,
>> WrapperOptions options)
>> throws SQLException {
>> }
>>
>> However, for the java.sql.Array, we only have a bind by index method in
>> java.sql.Statement:
>>
>> void setArray (int parameterIndex, Array x) throws SQLException;
>>
>> I remember that 6.0 is going to bind by index, so maybe this issue is
>> already taken care of in the new version.
>> Should we provide some fix for 5.x as well?
>>
>> Vlad
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>
More information about the hibernate-dev
mailing list