Skip to content

Commit ef1150e

Browse files
committed
add VERSION_ROLE_NAME constant
1 parent f98ce16 commit ef1150e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityVersionMapping.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* @see jakarta.persistence.Version
1515
*/
1616
public interface EntityVersionMapping extends BasicValuedModelPart {
17+
18+
String VERSION_ROLE_NAME = "{version}";
19+
1720
/**
1821
* The attribute marked as the version
1922
*/

tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/MockSessionFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.hibernate.EntityNameResolver;
1111
import org.hibernate.MappingException;
1212
import org.hibernate.SessionFactoryObserver;
13+
import org.hibernate.metamodel.mapping.EntityVersionMapping;
1314
import org.hibernate.type.TimeZoneStorageStrategy;
1415
import org.hibernate.boot.internal.DefaultCustomEntityDirtinessStrategy;
1516
import org.hibernate.boot.internal.MetadataImpl;
@@ -953,7 +954,7 @@ public MockEntityDomainType(JavaType<X> javaType, String jpaEntityName) {
953954
else {
954955
return new SingularAttributeImpl<>(
955956
MockEntityDomainType.this,
956-
"{version}",
957+
EntityVersionMapping.VERSION_ROLE_NAME,
957958
AttributeClassification.BASIC,
958959
type,
959960
type.getRelationalJavaType(),
@@ -1004,7 +1005,7 @@ public SqmPathSource<?> findSubPathSource(String name, boolean includeSubtypes)
10041005
switch (name) {
10051006
case EntityIdentifierMapping.ID_ROLE_NAME:
10061007
return getIdentifierDescriptor();
1007-
case "{version}":
1008+
case EntityVersionMapping.VERSION_ROLE_NAME:
10081009
return findVersionAttribute();
10091010
}
10101011
final SqmPathSource<?> source = super.findSubPathSource(name, includeSubtypes);

tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/ProcessorSessionFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.checkerframework.checker.nullness.qual.Nullable;
99
import org.hibernate.PropertyNotFoundException;
1010
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
11+
import org.hibernate.metamodel.mapping.EntityVersionMapping;
1112
import org.hibernate.type.BasicType;
1213
import org.hibernate.type.CollectionType;
1314
import org.hibernate.type.CompositeType;
@@ -436,7 +437,8 @@ public Type identifierType() {
436437
public BasicType<?> versionType() {
437438
for (Element element : type.getEnclosedElements()) {
438439
if ( hasAnnotation(element, "Version") ) {
439-
return (BasicType<?>) factory.propertyType(element, getEntityName(), "{version}", defaultAccessType);
440+
return (BasicType<?>) factory.propertyType(element, getEntityName(),
441+
EntityVersionMapping.VERSION_ROLE_NAME, defaultAccessType);
440442
}
441443
}
442444
return null;

0 commit comments

Comments
 (0)