Skip to content

Commit 0200216

Browse files
committed
HHH-9882 - many to one declarations in hbm without embed-xml="false" generate warning
1 parent fa14d4f commit 0200216

File tree

8 files changed

+42
-51
lines changed

8 files changed

+42
-51
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/CompositeIdentifierSingularAttributeSourceManyToOneImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ public String getReferencedEntityName() {
227227
}
228228

229229
@Override
230-
public boolean isEmbedXml() {
231-
return false;
230+
public Boolean isEmbedXml() {
231+
return null;
232232
}
233233

234234
@Override

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,10 +2112,10 @@ public void bindOneToOne(
21122112
// todo : probably need some reflection here if null
21132113
oneToOneBinding.setReferencedEntityName( oneToOneSource.getReferencedEntityName() );
21142114

2115-
if ( oneToOneSource.isEmbedXml() ) {
2115+
if ( oneToOneSource.isEmbedXml() == Boolean.TRUE ) {
21162116
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfEmbedXmlSupport();
21172117
}
2118-
oneToOneBinding.setEmbedded( oneToOneSource.isEmbedXml() );
2118+
oneToOneBinding.setEmbedded( oneToOneSource.isEmbedXml() != Boolean.FALSE );
21192119

21202120
if ( StringHelper.isNotEmpty( oneToOneSource.getExplicitForeignKeyName() ) ) {
21212121
oneToOneBinding.setForeignKeyName( oneToOneSource.getExplicitForeignKeyName() );
@@ -2231,10 +2231,10 @@ private void bindManyToOneAttribute(
22312231
: FetchMode.JOIN
22322232
);
22332233

2234-
if ( manyToOneSource.isEmbedXml() ) {
2234+
if ( manyToOneSource.isEmbedXml() == Boolean.TRUE ) {
22352235
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfEmbedXmlSupport();
22362236
}
2237-
manyToOneBinding.setEmbedded( manyToOneSource.isEmbedXml() );
2237+
manyToOneBinding.setEmbedded( manyToOneSource.isEmbedXml() != Boolean.FALSE );
22382238

22392239
manyToOneBinding.setIgnoreNotFound( manyToOneSource.isIgnoreNotFound() );
22402240

@@ -3526,15 +3526,6 @@ else if ( getPluralAttributeSource().getElementSource() instanceof PluralAttribu
35263526
elementBinding.setReferencedEntityName( referencedEntityBinding.getEntityName() );
35273527
elementBinding.setAssociatedClass( referencedEntityBinding );
35283528

3529-
String embed = elementSource.getXmlNodeName();
3530-
// sometimes embed is set to the default value when not specified in the mapping,
3531-
// so can't seem to determine if an attribute was explicitly set;
3532-
// log a warning if embed has a value different from the default.
3533-
if ( !StringHelper.isEmpty( embed ) && !"true".equals( embed ) ) {
3534-
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfEmbedXmlSupport();
3535-
}
3536-
elementBinding.setEmbedded( embed == null || "true".equals( embed ) );
3537-
35383529
elementBinding.setIgnoreNotFound( elementSource.isIgnoreNotFound() );
35393530
}
35403531
else if ( getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceManyToMany ) {

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/SingularAttributeSourceManyToOneImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public String getReferencedEntityName() {
175175
}
176176

177177
@Override
178-
public boolean isEmbedXml() {
178+
public Boolean isEmbedXml() {
179179
return manyToOneElement.isEmbedXml();
180180
}
181181

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/SingularAttributeSourceOneToOneImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public String getReferencedEntityAttributeName() {
222222
}
223223

224224
@Override
225-
public boolean isEmbedXml() {
225+
public Boolean isEmbedXml() {
226226
return oneToOneElement.isEmbedXml();
227227
}
228228
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/SingularAttributeSourceToOne.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ public interface SingularAttributeSourceToOne
2929

3030
public boolean isUnique();
3131

32-
public boolean isEmbedXml();
32+
public Boolean isEmbedXml();
3333
}

hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-3.0.dtd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ etc. to an entity). -->
409409
<!ATTLIST many-to-one lazy (false|proxy|no-proxy) #IMPLIED>
410410
<!ATTLIST many-to-one not-found (exception|ignore) "exception">
411411
<!ATTLIST many-to-one node CDATA #IMPLIED>
412-
<!ATTLIST many-to-one embed-xml (true|false) "true">
412+
<!ATTLIST many-to-one embed-xml (true|false) #IMPLIED>
413413

414414
<!-- Declares a one-to-one association between two entities (Or from a component,
415415
component element, etc. to an entity). -->
@@ -428,7 +428,7 @@ component element, etc. to an entity). -->
428428
<!ATTLIST one-to-one property-ref CDATA #IMPLIED>
429429
<!ATTLIST one-to-one lazy (false|proxy|no-proxy) #IMPLIED>
430430
<!ATTLIST one-to-one node CDATA #IMPLIED>
431-
<!ATTLIST one-to-one embed-xml (true|false) "true">
431+
<!ATTLIST one-to-one embed-xml (true|false) #IMPLIED>
432432

433433
<!-- A property embedded in a composite identifier or map index (always not-null). -->
434434

@@ -565,7 +565,7 @@ relationship from the collection table to the enclosing class. -->
565565
<!ATTLIST map collection-type CDATA #IMPLIED>
566566
<!ATTLIST map optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
567567
<!ATTLIST map node CDATA #IMPLIED>
568-
<!ATTLIST map embed-xml (true|false) "true">
568+
<!ATTLIST map embed-xml (true|false) #IMPLIED>
569569

570570
<!ELEMENT set (
571571
meta*,
@@ -599,7 +599,7 @@ relationship from the collection table to the enclosing class. -->
599599
<!ATTLIST set check CDATA #IMPLIED> <!-- default: none -->
600600
<!ATTLIST set optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
601601
<!ATTLIST set node CDATA #IMPLIED>
602-
<!ATTLIST set embed-xml (true|false) "true">
602+
<!ATTLIST set embed-xml (true|false) #IMPLIED>
603603

604604
<!ELEMENT bag (
605605
meta*,
@@ -632,7 +632,7 @@ relationship from the collection table to the enclosing class. -->
632632
<!ATTLIST bag check CDATA #IMPLIED> <!-- default: none -->
633633
<!ATTLIST bag optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
634634
<!ATTLIST bag node CDATA #IMPLIED>
635-
<!ATTLIST bag embed-xml (true|false) "true">
635+
<!ATTLIST bag embed-xml (true|false) #IMPLIED>
636636

637637
<!ELEMENT idbag (
638638
meta*,
@@ -665,7 +665,7 @@ relationship from the collection table to the enclosing class. -->
665665
<!ATTLIST idbag check CDATA #IMPLIED> <!-- default: none -->
666666
<!ATTLIST idbag optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
667667
<!ATTLIST idbag node CDATA #IMPLIED>
668-
<!ATTLIST idbag embed-xml (true|false) "true">
668+
<!ATTLIST idbag embed-xml (true|false) #IMPLIED>
669669

670670
<!ELEMENT list (
671671
meta*,
@@ -698,7 +698,7 @@ relationship from the collection table to the enclosing class. -->
698698
<!ATTLIST list check CDATA #IMPLIED> <!-- default: none -->
699699
<!ATTLIST list optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
700700
<!ATTLIST list node CDATA #IMPLIED>
701-
<!ATTLIST list embed-xml (true|false) "true">
701+
<!ATTLIST list embed-xml (true|false) #IMPLIED>
702702

703703
<!ELEMENT array (
704704
meta*,
@@ -730,7 +730,7 @@ relationship from the collection table to the enclosing class. -->
730730
<!ATTLIST array check CDATA #IMPLIED> <!-- default: none -->
731731
<!ATTLIST array optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
732732
<!ATTLIST array node CDATA #IMPLIED>
733-
<!ATTLIST array embed-xml (true|false) "true">
733+
<!ATTLIST array embed-xml (true|false) #IMPLIED>
734734

735735
<!ELEMENT primitive-array (
736736
meta*,
@@ -759,7 +759,7 @@ relationship from the collection table to the enclosing class. -->
759759
<!ATTLIST primitive-array check CDATA #IMPLIED> <!-- default: none -->
760760
<!ATTLIST primitive-array optimistic-lock (true|false) "true"> <!-- only supported for properties of a class (not component) -->
761761
<!ATTLIST primitive-array node CDATA #IMPLIED>
762-
<!ATTLIST primitive-array embed-xml (true|false) "true">
762+
<!ATTLIST primitive-array embed-xml (true|false) #IMPLIED>
763763

764764
<!-- Declares the element type of a collection of basic type -->
765765

@@ -781,7 +781,7 @@ element type of a collection and specifies a one-to-many relational model -->
781781
<!ATTLIST one-to-many class CDATA #IMPLIED>
782782
<!ATTLIST one-to-many not-found (exception|ignore) "exception">
783783
<!ATTLIST one-to-many node CDATA #IMPLIED>
784-
<!ATTLIST one-to-many embed-xml (true|false) "true">
784+
<!ATTLIST one-to-many embed-xml (true|false) #IMPLIED>
785785
<!ATTLIST one-to-many entity-name CDATA #IMPLIED>
786786
<!-- No column declaration attributes required in this case. The primary
787787
key column of the associated class is already mapped elsewhere.-->
@@ -792,7 +792,7 @@ element type of a collection and specifies a many-to-many relational model -->
792792
<!ELEMENT many-to-many (meta*,(column|formula)*,filter*)>
793793
<!ATTLIST many-to-many class CDATA #IMPLIED>
794794
<!ATTLIST many-to-many node CDATA #IMPLIED>
795-
<!ATTLIST many-to-many embed-xml (true|false) "true">
795+
<!ATTLIST many-to-many embed-xml (true|false) #IMPLIED>
796796
<!ATTLIST many-to-many entity-name CDATA #IMPLIED>
797797
<!ATTLIST many-to-many column CDATA #IMPLIED>
798798
<!ATTLIST many-to-many formula CDATA #IMPLIED>

hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
435435
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
436436
<xs:attribute name="collection-type" type="xs:string"/>
437437
<xs:attribute name="element-class" type="xs:string"/>
438-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
438+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
439439
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
440440
<xs:attribute name="inverse" default="false" type="xs:boolean"/>
441441
<xs:attribute name="mutable" default="true" type="xs:boolean"/>
@@ -479,7 +479,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
479479
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
480480
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
481481
<xs:attribute name="collection-type" type="xs:string"/>
482-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
482+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
483483
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
484484
<xs:attribute name="inverse" default="false" type="xs:boolean"/>
485485
<xs:attribute name="lazy" type="lazy-attribute-with-extra"/>
@@ -748,7 +748,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
748748
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
749749
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
750750
<xs:attribute name="collection-type" type="xs:string"/>
751-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
751+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
752752
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
753753
<xs:attribute name="lazy" type="lazy-attribute-with-extra"/>
754754
<xs:attribute name="mutable" default="true" type="xs:boolean"/>
@@ -954,7 +954,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
954954
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
955955
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
956956
<xs:attribute name="collection-type" type="xs:string"/>
957-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
957+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
958958
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
959959
<xs:attribute name="inverse" default="false" type="xs:boolean"/>
960960
<xs:attribute name="lazy" type="lazy-attribute-with-extra"/>
@@ -1022,7 +1022,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
10221022
</xs:sequence>
10231023
<xs:attribute name="class" type="xs:string"/>
10241024
<xs:attribute name="column" type="xs:string"/>
1025-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1025+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true"-->
10261026
<xs:attribute name="entity-name" type="xs:string"/>
10271027
<xs:attribute name="fetch" type="fetch-attribute"/>
10281028
<xs:attribute name="foreign-key" type="xs:string"/>
@@ -1053,7 +1053,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
10531053
<xs:attribute name="cascade" type="xs:string"/>
10541054
<xs:attribute name="class" type="xs:string"/>
10551055
<xs:attribute name="column" type="xs:string"/>
1056-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1056+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
10571057
<xs:attribute name="entity-name" type="xs:string"/>
10581058
<xs:attribute name="fetch" type="fetch-attribute"/>
10591059
<xs:attribute name="foreign-key" type="xs:string"/>
@@ -1187,7 +1187,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
11871187
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
11881188
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
11891189
<xs:attribute name="collection-type" type="xs:string"/>
1190-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1190+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
11911191
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
11921192
<xs:attribute name="inverse" default="false" type="xs:boolean"/>
11931193
<xs:attribute name="lazy" type="lazy-attribute-with-extra"/>
@@ -1245,7 +1245,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
12451245
element type of a collection and specifies a one-to-many relational model -->
12461246
<xs:complexType name="one-to-many-element">
12471247
<xs:attribute name="class" type="xs:string"/>
1248-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1248+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
12491249
<xs:attribute name="entity-name" type="xs:string"/>
12501250
<xs:attribute name="node" type="xs:string"/>
12511251
<xs:attribute name="not-found" default="exception" type="not-found-attribute"/>
@@ -1264,7 +1264,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
12641264
<xs:attribute name="cascade" type="xs:string"/>
12651265
<xs:attribute name="class" type="xs:string"/>
12661266
<xs:attribute name="constrained" default="false" type="xs:boolean"/>
1267-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1267+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
12681268
<xs:attribute name="entity-name" type="xs:string"/>
12691269
<xs:attribute name="fetch" type="fetch-attribute"/>
12701270
<xs:attribute name="foreign-key" type="xs:string"/>
@@ -1315,7 +1315,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
13151315
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
13161316
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
13171317
<xs:attribute name="collection-type" type="xs:string"/>
1318-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1318+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
13191319
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
13201320
<xs:attribute name="mutable" default="true" type="xs:boolean"/>
13211321
<xs:attribute name="name" use="required" type="xs:string"/>
@@ -1502,7 +1502,7 @@ arbitrary number of queries, and import declarations of arbitrary classes.
15021502
<xs:attribute name="catalog" type="xs:string"/> <!-- default: none -->
15031503
<xs:attribute name="check" type="xs:string"/> <!-- default: none -->
15041504
<xs:attribute name="collection-type" type="xs:string"/>
1505-
<xs:attribute name="embed-xml" default="true" type="xs:boolean"/>
1505+
<xs:attribute name="embed-xml" type="xs:boolean"/> <!-- default="true" -->
15061506
<xs:attribute name="fetch" type="fetch-attribute-with-subselect"/>
15071507
<xs:attribute name="inverse" default="false" type="xs:boolean"/>
15081508
<xs:attribute name="lazy" type="lazy-attribute-with-extra"/>

0 commit comments

Comments
 (0)