Skip to content

Commit 187d8b8

Browse files
committed
HHH-10122 - Deprecate ".class" property-style entity-type-expression format
(cherry picked from commit e64d028)
1 parent 634707c commit 187d8b8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import org.hibernate.hql.internal.ast.util.ColumnHelper;
1515
import org.hibernate.internal.CoreLogging;
1616
import org.hibernate.internal.CoreMessageLogger;
17+
import org.hibernate.internal.log.DeprecationLogger;
1718
import org.hibernate.internal.util.StringHelper;
1819
import org.hibernate.persister.collection.QueryableCollection;
20+
import org.hibernate.persister.entity.AbstractEntityPersister;
1921
import org.hibernate.persister.entity.EntityPersister;
2022
import org.hibernate.persister.entity.Queryable;
2123
import org.hibernate.sql.JoinType;
@@ -198,8 +200,13 @@ public void resolve(boolean generateJoin, boolean implicitJoin, String classAlia
198200
if ( isResolved() ) {
199201
return;
200202
}
203+
201204
Type propertyType = prepareLhs(); // Prepare the left hand side and get the data type.
202205

206+
if ( parent == null && AbstractEntityPersister.ENTITY_CLASS.equals( propertyName ) ) {
207+
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfClassEntityTypeSelector( getLhs().getPath() );
208+
}
209+
203210
// If there is no data type for this node, and we're at the end of the path (top most dot node), then
204211
// this might be a Java constant.
205212
if ( propertyType == null ) {

hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,11 @@ void connectionProviderClassDeprecated(
186186
"use collection function syntax instead [%1$s(%2$s)]."
187187
)
188188
void logDeprecationOfCollectionPropertiesInHql(String collectionPropertyName, String alias);
189+
190+
@LogMessage(level = WARN)
191+
@Message(
192+
id = 90000017,
193+
value = "Found use of deprecated entity-type selector syntax in HQL/JPQL query ['%1$s.class']; use TYPE operator instead : type(%1$s)"
194+
)
195+
void logDeprecationOfClassEntityTypeSelector(String path);
189196
}

0 commit comments

Comments
 (0)