Skip to content

Commit dcd7ebb

Browse files
committed
clean up some warnings
use Metadata instead of deprecated Mapping (I'm not sure that's really an improvement)
1 parent d2b740c commit dcd7ebb

File tree

10 files changed

+48
-44
lines changed

10 files changed

+48
-44
lines changed

hibernate-core/src/main/java/org/hibernate/metadata/ClassMetadata.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ default Object instantiate(Object id, SessionImplementor session) {
201201
* @deprecated Use {@link #getIdentifier(Object,SharedSessionContractImplementor)} instead
202202
*/
203203
@Deprecated
204-
Object getIdentifier(Object object) throws HibernateException;
204+
default Object getIdentifier(Object object) throws HibernateException {
205+
return getIdentifier( object, null );
206+
}
205207

206208
/**
207209
* Get the identifier of an instance (throw an exception if no identifier property)

hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ else if ( indexedCollection instanceof org.hibernate.mapping.Map
613613
elementColumnReaderTemplates,
614614
elementFormulaTemplates,
615615
(CompositeType) elementType,
616-
factory
617-
);
616+
creationContext.getMetadata()
617+
);
618618
}
619619
else if ( !elementType.isEntityType() ) {
620620
elementPropertyMapping = new ElementPropertyMapping(

hibernate-core/src/main/java/org/hibernate/persister/collection/CompositeElementPropertyMapping.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
package org.hibernate.persister.collection;
88
import org.hibernate.MappingException;
9-
import org.hibernate.engine.spi.Mapping;
9+
import org.hibernate.boot.Metadata;
1010
import org.hibernate.persister.entity.AbstractPropertyMapping;
1111
import org.hibernate.type.CompositeType;
1212
import org.hibernate.type.Type;
@@ -24,13 +24,13 @@ public CompositeElementPropertyMapping(
2424
String[] elementColumnReaderTemplates,
2525
String[] elementFormulaTemplates,
2626
CompositeType compositeType,
27-
Mapping factory)
27+
Metadata factory)
2828
throws MappingException {
2929

3030
this.compositeType = compositeType;
3131

3232
initComponentPropertyPaths(null, compositeType, elementColumns, elementColumnReaders,
33-
elementColumnReaderTemplates, elementFormulaTemplates, factory);
33+
elementColumnReaderTemplates, elementFormulaTemplates, factory );
3434

3535
}
3636

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.hibernate.Session;
4646
import org.hibernate.StaleObjectStateException;
4747
import org.hibernate.StaleStateException;
48+
import org.hibernate.boot.Metadata;
4849
import org.hibernate.boot.spi.SessionFactoryOptions;
4950
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
5051
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
@@ -85,7 +86,6 @@
8586
import org.hibernate.engine.spi.EntityKey;
8687
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
8788
import org.hibernate.engine.spi.LoadQueryInfluencers;
88-
import org.hibernate.engine.spi.Mapping;
8989
import org.hibernate.engine.spi.NaturalIdResolutions;
9090
import org.hibernate.engine.spi.PersistenceContext;
9191
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
@@ -2694,7 +2694,7 @@ protected boolean hasWhere() {
26942694
return sqlWhereStringTemplate != null;
26952695
}
26962696

2697-
private void initOrdinaryPropertyPaths(Mapping mapping) throws MappingException {
2697+
private void initOrdinaryPropertyPaths(Metadata mapping) throws MappingException {
26982698
for ( int i = 0; i < getSubclassPropertyNameClosure().length; i++ ) {
26992699
propertyMapping.initPropertyPaths(
27002700
getSubclassPropertyNameClosure()[i],
@@ -2708,7 +2708,7 @@ private void initOrdinaryPropertyPaths(Mapping mapping) throws MappingException
27082708
}
27092709
}
27102710

2711-
private void initIdentifierPropertyPaths(Mapping mapping) throws MappingException {
2711+
private void initIdentifierPropertyPaths(Metadata mapping) throws MappingException {
27122712
String idProp = getIdentifierPropertyName();
27132713
if ( idProp != null ) {
27142714
propertyMapping.initPropertyPaths(
@@ -2730,24 +2730,24 @@ ENTITY_ID, getIdentifierType(), getIdentifierColumnNames(),
27302730
}
27312731
}
27322732

2733-
private void initDiscriminatorPropertyPath() {
2733+
private void initDiscriminatorPropertyPath(Metadata mapping) {
27342734
propertyMapping.initPropertyPaths(
27352735
ENTITY_CLASS,
27362736
getDiscriminatorType(),
27372737
new String[] {getDiscriminatorColumnName()},
27382738
new String[] {getDiscriminatorColumnReaders()},
27392739
new String[] {getDiscriminatorColumnReaderTemplate()},
27402740
new String[] {getDiscriminatorFormulaTemplate()},
2741-
getFactory()
2741+
mapping
27422742
);
27432743
}
27442744

2745-
protected void initPropertyPaths(Mapping mapping) throws MappingException {
2745+
protected void initPropertyPaths(Metadata mapping) throws MappingException {
27462746
initOrdinaryPropertyPaths( mapping );
27472747
initOrdinaryPropertyPaths( mapping ); //do two passes, for collection property-ref!
27482748
initIdentifierPropertyPaths( mapping );
27492749
if ( entityMetamodel.isPolymorphic() ) {
2750-
initDiscriminatorPropertyPath();
2750+
initDiscriminatorPropertyPath( mapping );
27512751
}
27522752
}
27532753

@@ -4054,7 +4054,7 @@ protected boolean isSubclassTableIndicatedByTreatAsDeclarations(
40544054
*
40554055
* @throws MappingException Indicates a problem accessing the Mapping
40564056
*/
4057-
protected void postConstruct(Mapping mapping) throws MappingException {
4057+
protected void postConstruct(Metadata mapping) throws MappingException {
40584058
initPropertyPaths( mapping );
40594059

40604060
//doLateInit();
@@ -5054,11 +5054,6 @@ private Object getPropertyValue(
50545054
return getPropertyValue( baseValue, baseValueType, propertyName, nextDotIndex );
50555055
}
50565056

5057-
@Override @Deprecated
5058-
public Object getIdentifier(Object object) {
5059-
return getIdentifier( object, null );
5060-
}
5061-
50625057
@Override
50635058
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
50645059
return identifierMapping.getIdentifier( entity );
@@ -5160,8 +5155,12 @@ public EntityPersister getSubclassEntityPersister(Object instance, SessionFactor
51605155
}
51615156
}
51625157

5163-
@Override @Deprecated
5158+
@Override @Deprecated(since = "6.0")
51645159
public boolean isMultiTable() {
5160+
return hasMultipleTables();
5161+
}
5162+
5163+
protected boolean hasMultipleTables() {
51655164
return false;
51665165
}
51675166

@@ -5585,7 +5584,7 @@ public void prepareMappingModel(MappingModelCreationProcess creationProcess) {
55855584
}
55865585
);
55875586

5588-
boolean needsMultiTableInsert = isMultiTable();
5587+
boolean needsMultiTableInsert = hasMultipleTables();
55895588
if ( needsMultiTableInsert ) {
55905589
creationProcess.registerInitializationCallback(
55915590
"Entity(" + getEntityName() + ") `sqmMultiTableMutationStrategy` interpretation",
@@ -5741,7 +5740,7 @@ private NaturalIdMapping generateNaturalIdMapping(MappingModelCreationProcess cr
57415740
protected static SqmMultiTableMutationStrategy interpretSqmMultiTableStrategy(
57425741
AbstractEntityPersister entityMappingDescriptor,
57435742
MappingModelCreationProcess creationProcess) {
5744-
assert entityMappingDescriptor.isMultiTable();
5743+
assert entityMappingDescriptor.hasMultipleTables();
57455744

57465745
EntityMappingType superMappingType = entityMappingDescriptor.getSuperMappingType();
57475746
if ( superMappingType != null ) {

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.hibernate.MappingException;
1515
import org.hibernate.QueryException;
16+
import org.hibernate.boot.Metadata;
1617
import org.hibernate.boot.spi.MetadataImplementor;
1718
import org.hibernate.engine.spi.Mapping;
1819
import org.hibernate.internal.CoreLogging;
@@ -134,7 +135,7 @@ protected void addPropertyPath(
134135
String[] columnReaders,
135136
String[] columnReaderTemplates,
136137
String[] formulaTemplates,
137-
Mapping factory) {
138+
Metadata factory) {
138139
Type existingType = typesByPropertyPath.get( path );
139140
if ( existingType != null || ( duplicateIncompatiblePaths != null && duplicateIncompatiblePaths.contains( path ) ) ) {
140141
// If types match or the new type is not an association type, there is nothing for us to do
@@ -265,7 +266,7 @@ protected void initPropertyPaths(
265266
String[] columnReaders,
266267
String[] columnReaderTemplates,
267268
final String[] formulaTemplates,
268-
final Mapping factory) throws MappingException {
269+
final Metadata factory) throws MappingException {
269270
assert columns != null : "Incoming columns should not be null : " + path;
270271
assert type != null : "Incoming type should not be null : " + path;
271272

@@ -344,7 +345,7 @@ protected void initIdentifierPropertyPaths(
344345
final String[] columns,
345346
final String[] columnReaders,
346347
final String[] columnReaderTemplates,
347-
final Mapping factory) throws MappingException {
348+
final Metadata factory) throws MappingException {
348349
initIdentifierPropertyPaths(path, etype, columns, columnReaders, columnReaderTemplates, null, factory);
349350
}
350351

@@ -355,7 +356,7 @@ protected void initIdentifierPropertyPaths(
355356
final String[] columnReaders,
356357
final String[] columnReaderTemplates,
357358
final String[] formulaTemplates,
358-
final Mapping factory) throws MappingException {
359+
final Metadata factory) throws MappingException {
359360

360361
Type idtype = etype.getIdentifierOrUniqueKeyType( factory );
361362
String idPropName = etype.getIdentifierOrUniqueKeyPropertyName( factory );
@@ -398,7 +399,7 @@ protected void initComponentPropertyPaths(
398399
final String[] columnReaders,
399400
final String[] columnReaderTemplates,
400401
final String[] formulaTemplates,
401-
final Mapping factory) throws MappingException {
402+
final Metadata factory) throws MappingException {
402403

403404
Type[] types = type.getSubtypes();
404405
String[] properties = type.getPropertyNames();

hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,14 @@ else if ( persistentClass.isDiscriminatorValueNotNull() ) {
510510
propTableNumbers.add( tableNumber );
511511

512512
for ( Selectable selectable : property.getSelectables() ) {
513-
if ( selectable.isFormula() ) {
514-
// formulaTableNumbers.add( tableNumber );
515-
}
516-
else {
513+
if ( !selectable.isFormula() ) {
517514
columnTableNumbers.add( tableNumber );
518515
Column column = (Column) selectable;
519516
columns.add( column.getQuotedName( dialect ) );
520517
}
518+
// else {
519+
// formulaTableNumbers.add( tableNumber );
520+
// }
521521
}
522522
}
523523

@@ -1009,8 +1009,8 @@ public int getTableSpan() {
10091009
return tableSpan;
10101010
}
10111011

1012-
@Override @Deprecated
1013-
public boolean isMultiTable() {
1012+
@Override
1013+
protected boolean hasMultipleTables() {
10141014
return true;
10151015
}
10161016

hibernate-core/src/main/java/org/hibernate/persister/entity/Queryable.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public interface Queryable extends Loadable, PropertyMapping, Joinable {
5050
* @deprecated Use {@link EntityPersister#getSqmMultiTableMutationStrategy} instead
5151
*/
5252
@Deprecated(since = "6.0")
53-
boolean isMultiTable();
53+
default boolean isMultiTable() {
54+
return false;
55+
}
5456

5557
/**
5658
* Get the names of all tables used in the hierarchy (up and down) ordered such

hibernate-core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ private boolean needsDiscriminator() {
649649
private String[] decodeTreatAsRequests(Set<String> treatAsDeclarations) {
650650
final List<String> values = new ArrayList<>();
651651
for ( String subclass : treatAsDeclarations ) {
652+
//TODO: move getDiscriminatorSQLValue() to Loadable to get rid of Queryable
652653
final Queryable queryable = (Queryable) getFactory()
653654
.getRuntimeMetamodels()
654655
.getMappingMetamodel()
@@ -707,7 +708,7 @@ private Object[] fullDiscriminatorValues() {
707708
// first access; build it
708709
final List<Object> values = new ArrayList<>();
709710
for ( String subclass : getSubclassClosure() ) {
710-
final Queryable queryable = (Queryable) getFactory().getRuntimeMetamodels()
711+
final Loadable queryable = (Loadable) getFactory().getRuntimeMetamodels()
711712
.getMappingMetamodel()
712713
.getEntityDescriptor( subclass );
713714
if ( !queryable.isAbstract() ) {
@@ -795,8 +796,8 @@ public String getPropertyTableName(String propertyName) {
795796
return index == null ? null : qualifiedTableNames[propertyTableNumbers[index]];
796797
}
797798

798-
@Override @Deprecated
799-
public boolean isMultiTable() {
799+
@Override
800+
protected boolean hasMultipleTables() {
800801
return getTableSpan() > 1;
801802
}
802803

hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import org.hibernate.AssertionFailure;
2424
import org.hibernate.HibernateException;
2525
import org.hibernate.MappingException;
26+
import org.hibernate.boot.Metadata;
2627
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
2728
import org.hibernate.cache.spi.access.EntityDataAccess;
2829
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
2930
import org.hibernate.dialect.Dialect;
3031
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
31-
import org.hibernate.engine.spi.Mapping;
3232
import org.hibernate.engine.spi.SessionFactoryImplementor;
3333
import org.hibernate.id.IdentityGenerator;
3434
import org.hibernate.internal.FilterAliasGenerator;
@@ -212,7 +212,7 @@ public UnionSubclassEntityPersister(
212212
}
213213
subclassTableExpressions = ArrayHelper.toStringArray( tableExpressions );
214214

215-
if ( isMultiTable() ) {
215+
if ( hasMultipleTables() ) {
216216
int idColumnSpan = getIdentifierColumnSpan();
217217
ArrayList<String> tableNames = new ArrayList<>();
218218
ArrayList<String[]> keyColumns = new ArrayList<>();
@@ -374,8 +374,8 @@ public int getSubclassPropertyTableNumber(String propertyName) {
374374
return 0;
375375
}
376376

377-
@Override @Deprecated
378-
public boolean isMultiTable() {
377+
@Override
378+
protected boolean hasMultipleTables() {
379379
// This could also just be true all the time...
380380
return isAbstract() || hasSubclasses();
381381
}
@@ -429,7 +429,7 @@ protected int[] getPropertyTableNumbers() {
429429
return new int[getPropertySpan()];
430430
}
431431

432-
protected String generateSubquery(PersistentClass model, Mapping mapping) {
432+
protected String generateSubquery(PersistentClass model, Metadata mapping) {
433433

434434
Dialect dialect = getFactory().getJdbcServices().getDialect();
435435
SqlStringGenerationContext sqlStringGenerationContext = getFactory().getSqlStringGenerationContext();
@@ -460,7 +460,7 @@ protected String generateSubquery(PersistentClass model, Mapping mapping) {
460460
buf.append( "select " );
461461
for ( Column col : columns ) {
462462
if ( !table.containsColumn(col) ) {
463-
int sqlType = col.getSqlTypeCode(mapping);
463+
int sqlType = col.getSqlTypeCode( mapping );
464464
buf.append( dialect.getSelectClauseNullString(sqlType) )
465465
.append(" as ");
466466
}

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/StandardTableExporter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import java.util.ArrayList;
1010
import java.util.Collections;
11-
import java.util.Iterator;
1211
import java.util.List;
1312

1413
import org.hibernate.MappingException;

0 commit comments

Comments
 (0)