Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void lock(Object id, Object version, Object object, int timeout, EventSou
lockable.getVersionType().nullSafeSet(
st,
version,
lockable.getIdentifierType().getColumnSpan( factory ) + 1,
lockable.getIdentifierType().getColumnSpan( factory.getRuntimeMetamodels() ) + 1,
session
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void lock(Object id, Object version, Object object, int timeout, EventSou
int offset = 2;

lockable.getIdentifierType().nullSafeSet( st, id, offset, session );
offset += lockable.getIdentifierType().getColumnSpan( factory );
offset += lockable.getIdentifierType().getColumnSpan( factory.getRuntimeMetamodels() );

if ( lockable.isVersioned() ) {
lockable.getVersionType().nullSafeSet( st, version, offset, session );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void lock(Object id, Object version, Object object, int timeout, EventSou
int offset = 2;

lockable.getIdentifierType().nullSafeSet( st, id, offset, session );
offset += lockable.getIdentifierType().getColumnSpan( factory );
offset += lockable.getIdentifierType().getColumnSpan( factory.getRuntimeMetamodels() );

if ( lockable.isVersioned() ) {
lockable.getVersionType().nullSafeSet( st, version, offset, session );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void lock(

final Type lockableIdentifierType = lockable.getIdentifierType();
lockableIdentifierType.nullSafeSet( st, id, offset, session );
offset += lockableIdentifierType.getColumnSpan( factory );
offset += lockableIdentifierType.getColumnSpan( factory.getRuntimeMetamodels() );

if ( lockable.isVersioned() ) {
lockableVersionType.nullSafeSet( st, version, offset, session );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* @author Gavin King
*
* @deprecated Use {@link org.hibernate.type.spi.TypeConfiguration},
* {@link org.hibernate.boot.Metadata}, or
* {@link org.hibernate.metamodel.RuntimeMetamodels}
* or {@link MappingContext}
* to access such information
* {@link org.hibernate.boot.Metadata},
* {@link org.hibernate.metamodel.RuntimeMetamodels},
* or {@link MappingContext} to access such information
*/
@Deprecated(since = "6.0")
@Deprecated(since = "6.0", forRemoval = true)
public interface Mapping extends MappingContext {
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
Expand Down Expand Up @@ -55,7 +54,6 @@
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducerProvider;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.generator.Generator;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;
Expand Down Expand Up @@ -298,21 +296,6 @@ public JavaType<Object> getTenantIdentifierJavaType() {
return delegate.getTenantIdentifierJavaType();
}

@Override
public Type getIdentifierType(String className) throws MappingException {
return delegate.getIdentifierType( className );
}

@Override
public String getIdentifierPropertyName(String className) throws MappingException {
return delegate.getIdentifierPropertyName( className );
}

@Override
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException {
return delegate.getReferencedPropertyType( className, propertyName );
}

@Override
public String getUuid() {
return delegate.getUuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.hibernate.generator.Generator;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.MappingContext;
import org.hibernate.type.spi.TypeConfiguration;

/**
Expand All @@ -50,7 +49,7 @@
* @author Gavin King
* @author Steve Ebersole
*/
public interface SessionFactoryImplementor extends MappingContext, SessionFactory {
public interface SessionFactoryImplementor extends SessionFactory {
/**
* The UUID assigned to this {@code SessionFactory}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected void bindParameters(Object entity, PreparedStatement ps, SharedSession
int index = 1;
for ( int i = 0; i < uniqueKeyPropertyNames.length; i++ ) {
uniqueKeyTypes[i].nullSafeSet( ps, persister.getPropertyValue( entity, uniqueKeyPropertyNames[i] ), index, session );
index += uniqueKeyTypes[i].getColumnSpan( session.getFactory() );
index += uniqueKeyTypes[i].getColumnSpan( session.getFactory().getRuntimeMetamodels() );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.SessionEventListener;
import org.hibernate.SessionFactory;
Expand Down Expand Up @@ -119,7 +118,6 @@
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducerProvider;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;
Expand Down Expand Up @@ -781,21 +779,6 @@ public Reference getReference() {
);
}

@Override
public Type getIdentifierType(String className) throws MappingException {
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getIdentifierType();
}

@Override
public String getIdentifierPropertyName(String className) throws MappingException {
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getIdentifierPropertyName();
}

@Override
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException {
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getPropertyType( propertyName );
}

/**
* Closes the session factory, releasing all held resources.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public EntityBatchLoaderInPredicate(
super( entityDescriptor, loadQueryInfluencers );
this.loadQueryInfluencers = loadQueryInfluencers;
this.domainBatchSize = domainBatchSize;
int idColumnCount = entityDescriptor.getEntityPersister().getIdentifierType().getColumnSpan( sessionFactory );
int idColumnCount =
entityDescriptor.getEntityPersister().getIdentifierType()
.getColumnSpan( sessionFactory .getRuntimeMetamodels());
this.sqlBatchSize = sessionFactory.getJdbcServices()
.getDialect()
.getBatchLoadSizingStrategy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public <T> EntityBatchLoader<T> createEntityBatchLoader(
final SessionFactoryImplementor factory = loadQueryInfluencers.getSessionFactory();
// NOTE : don't use the EntityIdentifierMapping here because it will not be known until later
final Type identifierType = entityDescriptor.getEntityPersister().getIdentifierType();
if ( identifierType.getColumnSpan( factory ) == 1
if ( identifierType.getColumnSpan( factory.getRuntimeMetamodels() ) == 1
&& supportsSqlArrayType( factory.getJdbcServices().getDialect() )
&& identifierType instanceof BasicType ) {
// we can use a single ARRAY parameter to send all the ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public void setFetchMode(FetchMode fetchMode) {
/**
* @deprecated use {@link #validate(MappingContext)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
public void validate(Mapping mapping) throws MappingException {
validate( (MappingContext) mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public boolean equals(Column column) {
/**
* @deprecated use {@link #getSqlTypeCode(MappingContext)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
public int getSqlTypeCode(Mapping mapping) throws MappingException{
return getSqlTypeCode((MappingContext) mapping);
}
Expand Down Expand Up @@ -425,7 +425,7 @@ public String getSqlType(Metadata mapping) {
/**
* @deprecated use {@link #getSqlType(Metadata)}
*/
@Deprecated(since = "6.2")
@Deprecated(since = "6.2", forRemoval = true)
public String getSqlType(TypeConfiguration typeConfiguration, Dialect dialect, Mapping mapping) {
return getSqlTypeName( typeConfiguration, dialect, mapping );
}
Expand Down Expand Up @@ -463,7 +463,7 @@ public int getDecimalDigits() {
/**
* @deprecated use {@link #getColumnSize(Dialect, MappingContext)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
public Size getColumnSize(Dialect dialect, Mapping mapping) {
return getColumnSize(dialect, (MappingContext) mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void createPrimaryKey() {
// create an index on the key columns??
}

@Deprecated(forRemoval = true)
public void validate(Mapping mapping) throws MappingException {
validate( (MappingContext) mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void createPrimaryKey() {
// }
}

@Deprecated
@Deprecated(forRemoval = true)
public void validate(Mapping mapping) throws MappingException {
validate( (MappingContext) mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void setMetaAttributes(Map<String, MetaAttribute> metas) {
/**
* @deprecated use {@link #isValid(MappingContext)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
public boolean isValid(Mapping mapping) throws MappingException {
return isValid( (MappingContext) mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Set copy() {
return new Set( this );
}

@Deprecated(forRemoval = true)
public void validate(Mapping mapping) throws MappingException {
validate( (MappingContext) mapping );
}
Expand Down
4 changes: 2 additions & 2 deletions hibernate-core/src/main/java/org/hibernate/mapping/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ default List<Column> getConstraintColumns() {
/**
* @deprecated use {@link #getSelectableType(MappingContext, int)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
default JdbcMapping getSelectableType(Mapping factory, int index) throws MappingException {
return getSelectableType( (MappingContext) factory, index );
}
Expand Down Expand Up @@ -146,7 +146,7 @@ private Type getIdType(EntityType entityType) {
/**
* @deprecated use {@link #isValid(MappingContext)}
*/
@Deprecated(since = "7.0")
@Deprecated(since = "7.0", forRemoval = true)
default boolean isValid(Mapping mapping) throws MappingException{
return isValid( (MappingContext) mapping );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
package org.hibernate.metamodel;

import org.hibernate.Incubating;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.NavigableRole;

/**
* Entry point providing access to the runtime metamodels:
Expand Down Expand Up @@ -42,21 +40,14 @@ default EntityMappingType getEntityMappingType(String entityName) {
return getMappingMetamodel().getEntityDescriptor( entityName );
}

default EntityMappingType getEntityMappingType(Class entityType) {
default EntityMappingType getEntityMappingType(Class<?> entityType) {
return getMappingMetamodel().getEntityDescriptor( entityType );
}

default PluralAttributeMapping getPluralAttributeMapping(String role) {
return getMappingMetamodel().findCollectionDescriptor( role ).getAttributeMapping();
}

/**
* @deprecated Use {@link #getEmbedded(NavigableRole)} instead
*/
@Deprecated
EmbeddableValuedModelPart getEmbedded(String role);
EmbeddableValuedModelPart getEmbedded(NavigableRole role);

default String getImportedName(String name) {
return getMappingMetamodel().getImportedName( name );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
*/
package org.hibernate.metamodel.internal;

import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.MappingException;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
import org.hibernate.type.Type;

/**
* @author Steve Ebersole
*/
public class RuntimeMetamodelsImpl implements RuntimeMetamodelsImplementor {

private JpaMetamodelImplementor jpaMetamodel;
private MappingMetamodelImplementor mappingMetamodel;

Expand All @@ -31,15 +32,21 @@
}

@Override
public EmbeddableValuedModelPart getEmbedded(String role) {
throw new UnsupportedOperationException( "Locating EmbeddableValuedModelPart by (String) role is not supported" );
public Type getIdentifierType(String className) throws MappingException {
return mappingMetamodel.getEntityDescriptor( className ).getIdentifierType();
}

@Override
public EmbeddableValuedModelPart getEmbedded(NavigableRole role) {
return mappingMetamodel.getEmbeddableValuedModelPart( role );
public String getIdentifierPropertyName(String className) throws MappingException {
return mappingMetamodel.getEntityDescriptor( className ).getIdentifierPropertyName();
}

@Override
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException {
return mappingMetamodel.getEntityDescriptor( className ).getPropertyType( propertyName );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
EntityPersister.getPropertyType
should be avoided because it has been deprecated.
}


public void setMappingMetamodel(MappingMetamodelImplementor mappingMetamodel) {
this.mappingMetamodel = mappingMetamodel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,8 @@ public static void addPrefixedPropertyNames(
}
}
else if ( type instanceof EntityType entityType ) {
final Type identifierOrUniqueKeyType = entityType.getIdentifierOrUniqueKeyType( factory );
final Type identifierOrUniqueKeyType =
entityType.getIdentifierOrUniqueKeyType( factory.getRuntimeMetamodels() );
final String propertyName;
if ( entityType.isReferenceToPrimaryKey() ) {
propertyName = entityType.getAssociatedEntityPersister( factory ).getIdentifierPropertyName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static Expression applyCollation(
final SqmToSqlAstConverter converter =
creationState instanceof SqmToSqlAstConverter sqmToSqlAstConverter
? sqmToSqlAstConverter
: new FakeSqmToSqlAstConverter(creationState);
: new FakeSqmToSqlAstConverter( creationState );
sortExpression =
queryEngine.getSqmFunctionRegistry()
.findFunctionDescriptor( "collate" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.type.MappingContext;

/**
* SPI extending {@link RuntimeMetamodels}.
* SPI extending {@link RuntimeMetamodels} and mixing in {@link MappingContext}.
*
* @author Steve Ebersole
*/
public interface RuntimeMetamodelsImplementor extends RuntimeMetamodels {
public interface RuntimeMetamodelsImplementor extends RuntimeMetamodels, MappingContext {
@Override
MappingMetamodelImplementor getMappingMetamodel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public AbstractCollectionPersister(
else {
final Column col = (Column) selectable;
elementColumnNames[j] = col.getQuotedName( dialect );
elementColumnWriters[j] = col.getWriteExpr( elementBootDescriptor.getSelectableType( factory, j ), dialect );
elementColumnWriters[j] = col.getWriteExpr( elementBootDescriptor.getSelectableType( factory.getRuntimeMetamodels(), j ), dialect );
elementColumnReaders[j] = col.getReadExpr( dialect );
elementColumnReaderTemplates[j] = col.getTemplate(
dialect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ else if ( propertyType instanceof ComponentType componentType ) {
final Type[] propertyTypes = componentType.getSubtypes();
int aliasIndex = 0;
for ( int i = 0; i < propertyNames.length; i++ ) {
final int columnSpan = propertyTypes[i].getColumnSpan( loadable.getFactory() );
final int columnSpan = propertyTypes[i].getColumnSpan( loadable.getFactory().getRuntimeMetamodels() );
addFetchBuilder(
suffix,
loadable,
Expand Down
Loading
Loading