HHH-16388 - Configuration setting for wrapper Byte[]/Character[] treatment

This commit is contained in:
Steve Ebersole 2023-03-28 19:02:36 -05:00 committed by Christian Beikov
parent 5f0b571df6
commit b799da7b60
2 changed files with 60 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrate
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
import org.hibernate.type.WrapperArrayHandling;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery;
@ -2768,6 +2769,19 @@ public interface AvailableSettings {
@Incubating
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";
/**
* Configurable control over how to handle {@code Byte[]} and {@code Character[]} types
* encountered in the application domain model. Allowable semantics are defined by
* {@link WrapperArrayHandling}. Accepted values include:<ol>
* <li>{@link WrapperArrayHandling} instance</li>
* <li>case-insensitive name of a {@link WrapperArrayHandling} instance (e.g. {@code allow})</li>
* </ol>
*
* @since 6.2
*/
@Incubating
String WRAPPER_ARRAY_HANDLING = "hibernate.type.wrapper_array_handling";
/**
* Specifies the default strategy for storage of the timezone information for the zoned
* datetime types {@link java.time.OffsetDateTime} and {@link java.time.ZonedDateTime}.

View File

@ -0,0 +1,46 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.type;
import org.hibernate.type.descriptor.java.ByteArrayJavaType;
import org.hibernate.type.descriptor.java.CharacterArrayJavaType;
/**
* Possible options for how to handle {@code Byte[]} and {@code Character[]} basic mappings
* encountered in the application domain model.
*
* @author Steve Ebersole
*
* @since 6.2
*/
public enum WrapperArrayHandling {
/**
* Throw an informative and actionable error if the types are used explicitly in the domain model
*
* @implNote The default behavior
*/
DISALLOW,
/**
* Allows the use of the wrapper arrays. Stores the arrays using {@linkplain SqlTypes#ARRAY ARRAY}
* or {@linkplain SqlTypes#SQLXML SQLXML} SQL types to maintain proper null element semantics.
*/
ALLOW,
/**
* Allows the use of the wrapper arrays. Stores the arrays using {@linkplain SqlTypes#VARBINARY VARBINARY}
* and {@linkplain SqlTypes#VARCHAR VARCHAR}, disallowing null elements.
*
* @see ByteArrayJavaType
* @see CharacterArrayJavaType
*
* @implNote The pre-6.2 behavior
* @apiNote Hibernate recommends users who want the legacy semantic change the domain model to use
* {@code byte[]} and {@code char[]} rather than using this setting.
*/
LEGACY
}