SQLServer Always Encrypted not supported by hibernate

It seems hibernate does not support SQLServer Always Encrypted.

According to the documentation from microsoft:
the precision and scale of parameters targeting columns of the decimal and numeric SQL Server data types is the same as the precision and scale configured for the target column. API methods have been added to the SQLServerPreparedStatement, SQLServerCallableStatement, and SQLServerResultSet classes to accept precision and scale along with data values for parameters/columns representing decimal and numeric data types

Looking at the class org.hibernate.type.descriptor.sql.DecimalTypeDescriptor we see that the precision and scale are never sent. Hibernate determines this based on the value in the BigDecimal class.

@Override
	public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
		return new BasicBinder<X>( javaTypeDescriptor, this ) {
			@Override
			protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
				st.setBigDecimal( index, javaTypeDescriptor.unwrap( value, BigDecimal.class, options ) );
			}

			@Override
			protected void doBind(CallableStatement st, X value, String name, WrapperOptions options)
					throws SQLException {
				st.setBigDecimal( name, javaTypeDescriptor.unwrap( value, BigDecimal.class, options ) );
			}
		};
	}

Are there any plans in the future for supporting this?

I’m not sure what Hibernate should do here to support this use case. Could you elaborate a bit on the details? What kind of change do you envision?

As I delved further into this feature, I noticed sqlserver jdbc does not adhere to the standards of jdbc when it comes to always encrypted. It seems anyone using hibernate, who wishes to use always encrypted, would have to customize hibernate-core and quite possibly sqlserver jdbc driver.
In my case that is what I had to do to get it working.

The following is small detailed example based on using bigdecimal values.
According to microsoft documentation, they added api methods to their SQLServerPreparedStatement.
Hibernate would have to incorporate these not standard jdbc methods. The reason they added this is because they expect the database column’s precision and scale to be sent and not determined based on the value. Eg.: Value 258,09 would give a precision of 5 and scale 2, which does not match the database column decimal(18,2), 18 by 2.
JDBC API PreparedStatement does not have any methods to facilitate this.

I am not sure how huge the market is for using hibernate and always encrypted. When searching on google, I had a hard time finding anything specific relating this.
What change do I envision? My question was simply if hibernate had any plans of supporting this in the future. When I posted this message, I was still looking for a solution. Currently a yes or no answer would suffice, considering I have a solution in place.

I don’t think that Hibernate will provide type implementations for this out of the box as that would mean that Hibernate has to commit to a specific JDBC driver version. Having said that, I think it’s pretty easy for users to create custom types though which they can configure either globally in the Dialect or per attribute.