Skip to content

Commit c02eae1

Browse files
committed
HHH-16160 Fix some XML related issues that came up
1 parent c5f5e10 commit c02eae1

File tree

22 files changed

+1289
-240
lines changed

22 files changed

+1289
-240
lines changed

.idea/codeStyles/Project.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker_db.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ disable_userland_proxy() {
659659
sudo service docker stop
660660
echo "Updating /etc/docker/daemon.json..."
661661
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
662-
echo "New docker daemon config:"
663-
cat /etc/docker/daemon.json
664662
echo "Starting docker..."
665663
sudo service docker start
666664
echo "Service status:"

hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393

9494
import static org.hibernate.cfg.AvailableSettings.JPA_COMPLIANCE;
9595
import static org.hibernate.cfg.AvailableSettings.WRAPPER_ARRAY_HANDLING;
96+
import static org.hibernate.cfg.MappingSettings.XML_FORMAT_MAPPER_LEGACY_FORMAT;
9697
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
9798
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
9899

@@ -652,6 +653,7 @@ public static class MetadataBuildingOptionsImpl
652653
private final String schemaCharset;
653654
private final boolean xmlMappingEnabled;
654655
private final boolean allowExtensionsInCdi;
656+
private final boolean xmlFormatMapperLegacyFormat;
655657

656658
public MetadataBuildingOptionsImpl(StandardServiceRegistry serviceRegistry) {
657659
this.serviceRegistry = serviceRegistry;
@@ -670,6 +672,7 @@ public MetadataBuildingOptionsImpl(StandardServiceRegistry serviceRegistry) {
670672
BOOLEAN,
671673
true
672674
);
675+
xmlFormatMapperLegacyFormat = configService.getSetting( XML_FORMAT_MAPPER_LEGACY_FORMAT, BOOLEAN, false );
673676

674677
implicitDiscriminatorsForJoinedInheritanceSupported = configService.getSetting(
675678
AvailableSettings.IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS,
@@ -954,6 +957,11 @@ public boolean isAllowExtensionsInCdi() {
954957
return allowExtensionsInCdi;
955958
}
956959

960+
@Override
961+
public boolean isXmlFormatMapperLegacyFormatEnabled() {
962+
return xmlFormatMapperLegacyFormat;
963+
}
964+
957965
/**
958966
* Yuck. This is needed because JPA lets users define "global building options"
959967
* in {@code orm.xml} mappings. Forget that there are generally multiple

hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
166166
private Object validatorFactoryReference;
167167
private FormatMapper jsonFormatMapper;
168168
private FormatMapper xmlFormatMapper;
169+
private final boolean xmlFormatMapperLegacyFormatEnabled;
169170

170171
// SessionFactory behavior
171172
private final boolean jpaBootstrap;
@@ -323,7 +324,8 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
323324
);
324325
this.xmlFormatMapper = determineXmlFormatMapper(
325326
configurationSettings.get( AvailableSettings.XML_FORMAT_MAPPER ),
326-
strategySelector
327+
strategySelector,
328+
this.xmlFormatMapperLegacyFormatEnabled = context.getMetadataBuildingOptions().isXmlFormatMapperLegacyFormatEnabled()
327329
);
328330

329331
this.sessionFactoryName = (String) configurationSettings.get( SESSION_FACTORY_NAME );
@@ -866,13 +868,13 @@ private static FormatMapper determineJsonFormatMapper(Object setting, StrategySe
866868
);
867869
}
868870

869-
private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector) {
871+
private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector, boolean legacyFormat) {
870872
return strategySelector.resolveDefaultableStrategy(
871873
FormatMapper.class,
872874
setting,
873875
(Callable<FormatMapper>) () -> {
874-
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull();
875-
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper();
876+
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull( legacyFormat );
877+
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper( legacyFormat );
876878
}
877879
);
878880
}
@@ -1332,6 +1334,11 @@ public FormatMapper getXmlFormatMapper() {
13321334
return xmlFormatMapper;
13331335
}
13341336

1337+
@Override
1338+
public boolean isXmlFormatMapperLegacyFormatEnabled() {
1339+
return xmlFormatMapperLegacyFormatEnabled;
1340+
}
1341+
13351342
@Override
13361343
public boolean isPassProcedureParameterNames() {
13371344
return passProcedureParameterNames;

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,9 @@ public boolean isXmlMappingEnabled() {
182182
public boolean isAllowExtensionsInCdi() {
183183
return delegate.isAllowExtensionsInCdi();
184184
}
185+
186+
@Override
187+
public boolean isXmlFormatMapperLegacyFormatEnabled() {
188+
return delegate.isXmlFormatMapperLegacyFormatEnabled();
189+
}
185190
}

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ public FormatMapper getXmlFormatMapper() {
523523
return delegate.getXmlFormatMapper();
524524
}
525525

526+
@Override
527+
public boolean isXmlFormatMapperLegacyFormatEnabled() {
528+
return delegate.isXmlFormatMapperLegacyFormatEnabled();
529+
}
530+
526531
@Override
527532
public boolean isPassProcedureParameterNames() {
528533
return delegate.isPassProcedureParameterNames();

hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.util.List;
88

9+
import org.hibernate.Incubating;
910
import org.hibernate.TimeZoneStorageStrategy;
1011
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
1112
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
@@ -144,6 +145,15 @@ default CollectionSemanticsResolver getPersistentCollectionRepresentationResolve
144145
*/
145146
boolean isMultiTenancyEnabled();
146147

148+
/**
149+
* Whether to use the legacy format for serializing/deserializing XML data.
150+
*
151+
* @since 7.0
152+
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER_LEGACY_FORMAT
153+
*/
154+
@Incubating
155+
boolean isXmlFormatMapperLegacyFormatEnabled();
156+
147157
/**
148158
* @return the {@link TypeConfiguration} belonging to the {@link BootstrapContext}
149159
*/

hibernate-core/src/main/java/org/hibernate/boot/spi/SessionFactoryOptions.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,15 @@ default boolean isCollectionsInDefaultFetchGroupEnabled() {
571571
@Incubating
572572
FormatMapper getXmlFormatMapper();
573573

574+
/**
575+
* Whether to use the legacy format for serializing/deserializing XML data.
576+
*
577+
* @since 7.0
578+
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER_LEGACY_FORMAT
579+
*/
580+
@Incubating
581+
boolean isXmlFormatMapperLegacyFormatEnabled();
582+
574583
/**
575584
* The default tenant identifier java type to use, in case no explicit tenant identifier property is defined.
576585
*

hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ public interface MappingSettings {
325325
@Incubating
326326
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";
327327

328+
/**
329+
* Specifies whether to use the legacy provider specific and non-portable XML format for collections and byte arrays
330+
* for XML serialization/deserialization.
331+
* <p>
332+
* {@code false} by default. This property only exists for backwards compatibility.
333+
*
334+
* @since 7.0
335+
*/
336+
@Incubating
337+
String XML_FORMAT_MAPPER_LEGACY_FORMAT = "hibernate.type.xml_format_mapper.legacy_format";
338+
328339
/**
329340
* Configurable control over how to handle {@code Byte[]} and {@code Character[]} types
330341
* encountered in the application domain model. Allowable semantics are defined by

0 commit comments

Comments
 (0)