HHH-17086 Make JSON/XML format mappers modifiable in SessionFactoryOptionsBuilder
This commit is contained in:
parent
1c86d94a15
commit
bae6304546
|
@ -10,6 +10,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.Interceptor;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
|
@ -22,6 +23,7 @@ import org.hibernate.query.sqm.NullPrecedence;
|
|||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.type.format.FormatMapper;
|
||||
|
||||
/**
|
||||
* The contract for building a {@link SessionFactory} given a number of options.
|
||||
|
@ -696,6 +698,30 @@ public interface SessionFactoryBuilder {
|
|||
*/
|
||||
SessionFactoryBuilder enableJpaClosedCompliance(boolean enabled);
|
||||
|
||||
/**
|
||||
* Specifies a {@link FormatMapper format mapper} to use for serialization/deserialization of JSON properties.
|
||||
*
|
||||
* @param jsonFormatMapper The {@link FormatMapper} to use.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#JSON_FORMAT_MAPPER
|
||||
*/
|
||||
@Incubating
|
||||
SessionFactoryBuilder applyJsonFormatMapper(FormatMapper jsonFormatMapper);
|
||||
|
||||
/**
|
||||
* Specifies a {@link FormatMapper format mapper} to use for serialization/deserialization of XML properties.
|
||||
*
|
||||
* @param xmlFormatMapper The {@link FormatMapper} to use.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#XML_FORMAT_MAPPER
|
||||
*/
|
||||
@Incubating
|
||||
SessionFactoryBuilder applyXmlFormatMapper(FormatMapper xmlFormatMapper);
|
||||
|
||||
/**
|
||||
* After all options have been set, build the SessionFactory.
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hibernate.query.sqm.NullPrecedence;
|
|||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.type.format.FormatMapper;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -416,6 +417,18 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJsonFormatMapper(FormatMapper jsonFormatMapper) {
|
||||
this.optionsBuilder.applyJsonFormatMapper( jsonFormatMapper );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyXmlFormatMapper(FormatMapper xmlFormatMapper) {
|
||||
this.optionsBuilder.applyXmlFormatMapper( xmlFormatMapper );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableRefreshDetachedEntity() {
|
||||
this.optionsBuilder.disableRefreshDetachedEntity();
|
||||
|
|
|
@ -155,8 +155,8 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
// integration
|
||||
private Object beanManagerReference;
|
||||
private Object validatorFactoryReference;
|
||||
private final FormatMapper jsonFormatMapper;
|
||||
private final FormatMapper xmlFormatMapper;
|
||||
private FormatMapper jsonFormatMapper;
|
||||
private FormatMapper xmlFormatMapper;
|
||||
|
||||
// SessionFactory behavior
|
||||
private final boolean jpaBootstrap;
|
||||
|
@ -1238,6 +1238,14 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
this.validatorFactoryReference = validatorFactory;
|
||||
}
|
||||
|
||||
public void applyJsonFormatMapper(FormatMapper jsonFormatMapper) {
|
||||
this.jsonFormatMapper = jsonFormatMapper;
|
||||
}
|
||||
|
||||
public void applyXmlFormatMapper(FormatMapper xmlFormatMapper) {
|
||||
this.xmlFormatMapper = xmlFormatMapper;
|
||||
}
|
||||
|
||||
public void applySessionFactoryName(String sessionFactoryName) {
|
||||
this.sessionFactoryName = sessionFactoryName;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.query.sqm.NullPrecedence;
|
|||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.type.format.FormatMapper;
|
||||
|
||||
/**
|
||||
* Convenience base class for custom implementors of SessionFactoryBuilder, using delegation
|
||||
|
@ -390,6 +391,18 @@ public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionF
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyJsonFormatMapper(FormatMapper jsonFormatMapper) {
|
||||
delegate.applyJsonFormatMapper( jsonFormatMapper );
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder applyXmlFormatMapper(FormatMapper xmlFormatMapper) {
|
||||
delegate.applyXmlFormatMapper( xmlFormatMapper );
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactory build() {
|
||||
return delegate.build();
|
||||
|
|
|
@ -31,6 +31,7 @@ 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 org.hibernate.type.format.FormatMapper;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaDelete;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
|
@ -2747,6 +2748,7 @@ public interface AvailableSettings {
|
|||
* used, according to the listing order.
|
||||
*
|
||||
* @since 6.0
|
||||
* @see org.hibernate.boot.SessionFactoryBuilder#applyJsonFormatMapper(FormatMapper)
|
||||
*/
|
||||
@Incubating
|
||||
String JSON_FORMAT_MAPPER = "hibernate.type.json_format_mapper";
|
||||
|
@ -2765,6 +2767,7 @@ public interface AvailableSettings {
|
|||
* used, according to the listing order.
|
||||
*
|
||||
* @since 6.0.1
|
||||
* @see org.hibernate.boot.SessionFactoryBuilder#applyXmlFormatMapper(FormatMapper)
|
||||
*/
|
||||
@Incubating
|
||||
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";
|
||||
|
|
Loading…
Reference in New Issue