Skip to content

Commit 9aee5bb

Browse files
committed
HHH-19495 Remove the default "true" from optimistic-lock
so that no extra annotations are added unless explicitly defined.
1 parent 12118ee commit 9aee5bb

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbLockableAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
* @author Steve Ebersole
1111
*/
1212
public interface JaxbLockableAttribute extends JaxbPersistentAttribute {
13-
boolean isOptimisticLock();
13+
Boolean isOptimisticLock();
1414
void setOptimisticLock(Boolean value);
1515
}

hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/CommonAttributeProcessing.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ public static void applyOptimisticLock(
8484
JaxbLockableAttribute jaxbAttribute,
8585
MutableMemberDetails memberDetails,
8686
XmlDocumentContext xmlDocumentContext) {
87-
final boolean includeInOptimisticLock = jaxbAttribute.isOptimisticLock();
88-
final OptimisticLockAnnotation optLockAnn = (OptimisticLockAnnotation) memberDetails.applyAnnotationUsage(
89-
HibernateAnnotations.OPTIMISTIC_LOCK,
90-
xmlDocumentContext.getModelBuildingContext()
91-
);
92-
optLockAnn.excluded( !includeInOptimisticLock );
87+
final Boolean includeInOptimisticLock = jaxbAttribute.isOptimisticLock();
88+
89+
if ( includeInOptimisticLock != null ) {
90+
final OptimisticLockAnnotation optLockAnn = (OptimisticLockAnnotation) memberDetails.applyAnnotationUsage(
91+
HibernateAnnotations.OPTIMISTIC_LOCK,
92+
xmlDocumentContext.getModelBuildingContext()
93+
);
94+
optLockAnn.excluded( !includeInOptimisticLock );
95+
}
9396
}
9497

9598
public static void applyFetching(

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@
601601
<xsd:attribute name="access" type="orm:access-type"/>
602602
<!-- hbm: Hibernate's pluggable accessor spi -->
603603
<xsd:attribute name="attribute-accessor" type="xsd:string" />
604-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
604+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
605605
</xsd:complexType>
606606

607607
<xsd:group name="basic-type-group">
@@ -1027,7 +1027,7 @@
10271027
<xsd:attribute name="fetch-mode" type="orm:plural-fetch-mode"/>
10281028
<xsd:attribute name="access" type="orm:access-type"/>
10291029
<xsd:attribute name="attribute-accessor" type="xsd:string" />
1030-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
1030+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
10311031
<xsd:attribute name="classification" type="orm:limited-collection-classification-enum" />
10321032
</xsd:complexType>
10331033

@@ -1109,7 +1109,7 @@
11091109
<xsd:attribute name="name" type="xsd:string" use="required"/>
11101110
<xsd:attribute name="access" type="orm:access-type"/>
11111111
<xsd:attribute name="attribute-accessor" type="xsd:string" />
1112-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
1112+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
11131113
</xsd:complexType>
11141114

11151115
<!-- **************************************************** -->
@@ -1614,7 +1614,7 @@
16141614
<xsd:attribute name="orphan-removal" type="xsd:boolean"/>
16151615
<xsd:attribute name="classification" type="orm:limited-collection-classification-enum" />
16161616
<xsd:attribute name="not-found" type="orm:not-found-enum"/>
1617-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
1617+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
16181618
</xsd:complexType>
16191619

16201620
<!-- **************************************************** -->
@@ -1661,7 +1661,7 @@
16611661
<xsd:attribute name="optional" type="xsd:boolean"/>
16621662
<xsd:attribute name="access" type="orm:access-type"/>
16631663
<xsd:attribute name="attribute-accessor" type="xsd:string" />
1664-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
1664+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
16651665
<xsd:attribute name="maps-id" type="xsd:string"/>
16661666
<xsd:attribute name="id" type="xsd:boolean"/>
16671667
<xsd:attribute name="not-found" type="orm:not-found-enum"/>
@@ -2057,7 +2057,7 @@
20572057
<xsd:attribute name="orphan-removal" type="xsd:boolean"/>
20582058
<xsd:attribute name="classification" type="orm:limited-collection-classification-enum" />
20592059
<xsd:attribute name="not-found" type="orm:not-found-enum"/>
2060-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
2060+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
20612061
</xsd:complexType>
20622062

20632063
<!-- **************************************************** -->
@@ -2113,7 +2113,7 @@
21132113
<xsd:attribute name="optional" type="xsd:boolean"/>
21142114
<xsd:attribute name="access" type="orm:access-type"/>
21152115
<xsd:attribute name="attribute-accessor" type="xsd:string" />
2116-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
2116+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
21172117
<xsd:attribute name="mapped-by" type="xsd:string"/>
21182118
<xsd:attribute name="orphan-removal" type="xsd:boolean"/>
21192119
<xsd:attribute name="maps-id" type="xsd:string"/>
@@ -3139,7 +3139,7 @@
31393139
<xsd:attribute name="fetch" type="orm:fetch-type"/>
31403140
<xsd:attribute name="fetch-mode" type="orm:singular-fetch-mode"/>
31413141
<xsd:attribute name="optional" type="xsd:boolean"/>
3142-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
3142+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
31433143
</xsd:complexType>
31443144

31453145
<xsd:complexType name="any-discriminator">
@@ -3208,7 +3208,7 @@
32083208
<xsd:attribute name="fetch-mode" type="orm:plural-fetch-mode"/>
32093209
<xsd:attribute name="access" type="orm:access-type"/>
32103210
<xsd:attribute name="attribute-accessor" type="xsd:string" />
3211-
<xsd:attribute name="optimistic-lock" type="xsd:boolean" default="true" />
3211+
<xsd:attribute name="optimistic-lock" type="xsd:boolean" />
32123212
<xsd:attribute name="classification" type="orm:limited-collection-classification-enum" />
32133213
</xsd:complexType>
32143214

@@ -3532,4 +3532,4 @@
35323532
<xsd:attribute name="type" use="required" type="xsd:string"/>
35333533
</xsd:complexType>
35343534

3535-
</xsd:schema>
3535+
</xsd:schema>

0 commit comments

Comments
 (0)