Skip to content

Commit e286c67

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

File tree

20 files changed

+1270
-232
lines changed

20 files changed

+1270
-232
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
@@ -169,6 +169,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
169169
private Object validatorFactoryReference;
170170
private FormatMapper jsonFormatMapper;
171171
private FormatMapper xmlFormatMapper;
172+
private final boolean xmlFormatMapperLegacyFormatEnabled;
172173

173174
// SessionFactory behavior
174175
private final boolean jpaBootstrap;
@@ -326,7 +327,8 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
326327
);
327328
this.xmlFormatMapper = determineXmlFormatMapper(
328329
configurationSettings.get( AvailableSettings.XML_FORMAT_MAPPER ),
329-
strategySelector
330+
strategySelector,
331+
this.xmlFormatMapperLegacyFormatEnabled = context.getMetadataBuildingOptions().isXmlMappingEnabled()
330332
);
331333

332334
this.sessionFactoryName = (String) configurationSettings.get( SESSION_FACTORY_NAME );
@@ -892,13 +894,13 @@ private static FormatMapper determineJsonFormatMapper(Object setting, StrategySe
892894
);
893895
}
894896

895-
private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector) {
897+
private static FormatMapper determineXmlFormatMapper(Object setting, StrategySelector strategySelector, boolean legacyFormat) {
896898
return strategySelector.resolveDefaultableStrategy(
897899
FormatMapper.class,
898900
setting,
899901
(Callable<FormatMapper>) () -> {
900-
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull();
901-
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper();
902+
final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull( legacyFormat );
903+
return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper( legacyFormat );
902904
}
903905
);
904906
}
@@ -1358,6 +1360,11 @@ public FormatMapper getXmlFormatMapper() {
13581360
return xmlFormatMapper;
13591361
}
13601362

1363+
@Override
1364+
public boolean isXmlFormatMapperLegacyFormatEnabled() {
1365+
return xmlFormatMapperLegacyFormatEnabled;
1366+
}
1367+
13611368
@Override
13621369
public boolean isPassProcedureParameterNames() {
13631370
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
@@ -384,6 +384,15 @@ default boolean isCollectionsInDefaultFetchGroupEnabled() {
384384
@Incubating
385385
FormatMapper getXmlFormatMapper();
386386

387+
/**
388+
* Whether to use the legacy format for serializing/deserializing XML data.
389+
*
390+
* @since 7.0
391+
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER_LEGACY_FORMAT
392+
*/
393+
@Incubating
394+
boolean isXmlFormatMapperLegacyFormatEnabled();
395+
387396
/**
388397
* The default tenant identifier java type to use, in case no explicit tenant identifier property is defined.
389398
*

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,18 @@ public interface MappingSettings {
314314
@Incubating
315315
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";
316316

317+
/**
318+
* Specifies whether to use the legacy provider specific and non-portable XML format for collections and byte arrays
319+
* for XML serialization/deserialization.
320+
* <p>
321+
* {@code false} by default. This property only exists for backwards compatibility.
322+
*
323+
* @since 7.0
324+
* @see org.hibernate.boot.SessionFactoryBuilder#applyXmlFormatMapperLegacyFormat(boolean)
325+
*/
326+
@Incubating
327+
String XML_FORMAT_MAPPER_LEGACY_FORMAT = "hibernate.type.xml_format_mapper.legacy_format";
328+
317329
/**
318330
* Configurable control over how to handle {@code Byte[]} and {@code Character[]} types
319331
* encountered in the application domain model. Allowable semantics are defined by

0 commit comments

Comments
 (0)