Skip to content

Commit

Permalink
HHH-16160 Fix some XML related issues that came up
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 22, 2024
1 parent c5f5e10 commit c02eae1
Show file tree
Hide file tree
Showing 22 changed files with 1,289 additions and 240 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions docker_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ disable_userland_proxy() {
sudo service docker stop
echo "Updating /etc/docker/daemon.json..."
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
echo "New docker daemon config:"
cat /etc/docker/daemon.json
echo "Starting docker..."
sudo service docker start
echo "Service status:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@

import static org.hibernate.cfg.AvailableSettings.JPA_COMPLIANCE;
import static org.hibernate.cfg.AvailableSettings.WRAPPER_ARRAY_HANDLING;
import static org.hibernate.cfg.MappingSettings.XML_FORMAT_MAPPER_LEGACY_FORMAT;
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;

Expand Down Expand Up @@ -652,6 +653,7 @@ public static class MetadataBuildingOptionsImpl
private final String schemaCharset;
private final boolean xmlMappingEnabled;
private final boolean allowExtensionsInCdi;
private final boolean xmlFormatMapperLegacyFormat;

public MetadataBuildingOptionsImpl(StandardServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
Expand All @@ -670,6 +672,7 @@ public MetadataBuildingOptionsImpl(StandardServiceRegistry serviceRegistry) {
BOOLEAN,
true
);
xmlFormatMapperLegacyFormat = configService.getSetting( XML_FORMAT_MAPPER_LEGACY_FORMAT, BOOLEAN, false );

implicitDiscriminatorsForJoinedInheritanceSupported = configService.getSetting(
AvailableSettings.IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
Expand Down Expand Up @@ -954,6 +957,11 @@ public boolean isAllowExtensionsInCdi() {
return allowExtensionsInCdi;
}

@Override
public boolean isXmlFormatMapperLegacyFormatEnabled() {
return xmlFormatMapperLegacyFormat;
}

/**
* Yuck. This is needed because JPA lets users define "global building options"
* in {@code orm.xml} mappings. Forget that there are generally multiple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private Object validatorFactoryReference;
private FormatMapper jsonFormatMapper;
private FormatMapper xmlFormatMapper;
private final boolean xmlFormatMapperLegacyFormatEnabled;

// SessionFactory behavior
private final boolean jpaBootstrap;
Expand Down Expand Up @@ -323,7 +324,8 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
);
this.xmlFormatMapper = determineXmlFormatMapper(
configurationSettings.get( AvailableSettings.XML_FORMAT_MAPPER ),
strategySelector
strategySelector,
this.xmlFormatMapperLegacyFormatEnabled = context.getMetadataBuildingOptions().isXmlFormatMapperLegacyFormatEnabled()
);

this.sessionFactoryName = (String) configurationSettings.get( SESSION_FACTORY_NAME );
Expand Down Expand Up @@ -866,13 +868,13 @@ private static FormatMapper determineJsonFormatMapper(Object setting, StrategySe
);
}

private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector) {
private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector, boolean legacyFormat) {
return strategySelector.resolveDefaultableStrategy(
FormatMapper.class,
setting,
(Callable<FormatMapper>) () -> {
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull();
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper();
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull( legacyFormat );
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper( legacyFormat );
}
);
}
Expand Down Expand Up @@ -1332,6 +1334,11 @@ public FormatMapper getXmlFormatMapper() {
return xmlFormatMapper;
}

@Override
public boolean isXmlFormatMapperLegacyFormatEnabled() {
return xmlFormatMapperLegacyFormatEnabled;
}

@Override
public boolean isPassProcedureParameterNames() {
return passProcedureParameterNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,9 @@ public boolean isXmlMappingEnabled() {
public boolean isAllowExtensionsInCdi() {
return delegate.isAllowExtensionsInCdi();
}

@Override
public boolean isXmlFormatMapperLegacyFormatEnabled() {
return delegate.isXmlFormatMapperLegacyFormatEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ public FormatMapper getXmlFormatMapper() {
return delegate.getXmlFormatMapper();
}

@Override
public boolean isXmlFormatMapperLegacyFormatEnabled() {
return delegate.isXmlFormatMapperLegacyFormatEnabled();
}

@Override
public boolean isPassProcedureParameterNames() {
return delegate.isPassProcedureParameterNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.List;

import org.hibernate.Incubating;
import org.hibernate.TimeZoneStorageStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
Expand Down Expand Up @@ -144,6 +145,15 @@ default CollectionSemanticsResolver getPersistentCollectionRepresentationResolve
*/
boolean isMultiTenancyEnabled();

/**
* Whether to use the legacy format for serializing/deserializing XML data.
*
* @since 7.0
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER_LEGACY_FORMAT
*/
@Incubating
boolean isXmlFormatMapperLegacyFormatEnabled();

/**
* @return the {@link TypeConfiguration} belonging to the {@link BootstrapContext}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,15 @@ default boolean isCollectionsInDefaultFetchGroupEnabled() {
@Incubating
FormatMapper getXmlFormatMapper();

/**
* Whether to use the legacy format for serializing/deserializing XML data.
*
* @since 7.0
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER_LEGACY_FORMAT
*/
@Incubating
boolean isXmlFormatMapperLegacyFormatEnabled();

/**
* The default tenant identifier java type to use, in case no explicit tenant identifier property is defined.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ public interface MappingSettings {
@Incubating
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";

/**
* Specifies whether to use the legacy provider specific and non-portable XML format for collections and byte arrays
* for XML serialization/deserialization.
* <p>
* {@code false} by default. This property only exists for backwards compatibility.
*
* @since 7.0
*/
@Incubating
String XML_FORMAT_MAPPER_LEGACY_FORMAT = "hibernate.type.xml_format_mapper.legacy_format";

/**
* Configurable control over how to handle {@code Byte[]} and {@code Character[]} types
* encountered in the application domain model. Allowable semantics are defined by
Expand Down
Loading

0 comments on commit c02eae1

Please sign in to comment.