actually remove deprecated operations of SessionFactoryImplementor and SessionImplementor

This commit is contained in:
Gavin King 2022-01-23 11:09:18 +01:00
parent 4b26cb5876
commit 9724fb0d9b
84 changed files with 242 additions and 508 deletions

View File

@ -1299,9 +1299,7 @@ public interface Session extends SharedSessionContract, EntityManager {
RootGraph<?> getEntityGraph(String graphName); RootGraph<?> getEntityGraph(String graphName);
@Override @Override
default <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) { <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass);
return getSessionFactory().findEntityGraphsByType( entityClass );
}
// The following overrides should not be necessary, // The following overrides should not be necessary,
// and are only needed to work around a bug in IntelliJ // and are only needed to work around a bug in IntelliJ

View File

@ -41,7 +41,7 @@ public class StructuredCacheEntry implements CacheEntryStructure {
final Map map = (Map) structured; final Map map = (Map) structured;
final String subclass = (String) map.get( SUBCLASS_KEY ); final String subclass = (String) map.get( SUBCLASS_KEY );
final Object version = map.get( VERSION_KEY ); final Object version = map.get( VERSION_KEY );
final EntityPersister subclassPersister = factory.getEntityPersister( subclass ); final EntityPersister subclassPersister = factory.getMetamodel().entityPersister(subclass);
final String[] names = subclassPersister.getPropertyNames(); final String[] names = subclassPersister.getPropertyNames();
final Serializable[] disassembledState = new Serializable[names.length]; final Serializable[] disassembledState = new Serializable[names.length];
for ( int i = 0; i < names.length; i++ ) { for ( int i = 0; i < names.length; i++ ) {

View File

@ -245,7 +245,7 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
} }
session.getPersistenceContextInternal().addUninitializedDetachedCollection( session.getPersistenceContextInternal().addUninitializedDetachedCollection(
session.getFactory().getCollectionPersister( getRole() ), session.getFactory().getMetamodel().collectionPersister(getRole()),
this this
); );
} }
@ -480,7 +480,7 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
* Replace entity instances with copy in {@code copyCache}/. * Replace entity instances with copy in {@code copyCache}/.
* *
* @param copyCache - mapping from entity in the process of being * @param copyCache - mapping from entity in the process of being
* merged to managed copy. * merged to managed copy.
*/ */
public final void replaceQueuedOperationValues(CollectionPersister persister, Map copyCache) { public final void replaceQueuedOperationValues(CollectionPersister persister, Map copyCache) {
for ( DelayedOperation<?> operation : operationQueue ) { for ( DelayedOperation<?> operation : operationQueue ) {
@ -1214,7 +1214,7 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
return oldElements; return oldElements;
} }
final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); final EntityPersister entityPersister = session.getFactory().getMetamodel().entityPersister(entityName);
final Type idType = entityPersister.getIdentifierType(); final Type idType = entityPersister.getIdentifierType();
final boolean useIdDirect = mayUseIdDirect( idType ); final boolean useIdDirect = mayUseIdDirect( idType );
@ -1281,7 +1281,7 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) { if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) {
final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); final EntityPersister entityPersister = session.getFactory().getMetamodel().entityPersister(entityName);
final Type idType = entityPersister.getIdentifierType(); final Type idType = entityPersister.getIdentifierType();
final Object idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session ); final Object idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
@ -1306,7 +1306,7 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
* @param session The session * @param session The session
* *
* @deprecated {@link #identityRemove(Collection, Object, String, SharedSessionContractImplementor)} * @deprecated {@link #identityRemove(Collection, Object, String, SharedSessionContractImplementor)}
* should be used instead. * should be used instead.
*/ */
@Deprecated @Deprecated
public static void identityRemove( public static void identityRemove(

View File

@ -121,7 +121,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() { protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory(); final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getJdbcServices().getDialect() ); final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() ); update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() ); update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -119,7 +119,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() { protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory(); final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getJdbcServices().getDialect() ); final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() ); update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() ); update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -123,7 +123,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() { protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory(); final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getJdbcServices().getDialect() ); final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() ); update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() ); update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() ); update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -108,7 +108,6 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
/** /**
* This for is used during custom deserialization handling * This for is used during custom deserialization handling
*/ */
@SuppressWarnings( {"JavaDoc"})
protected AbstractEntityEntry( protected AbstractEntityEntry(
final SessionFactoryImplementor factory, final SessionFactoryImplementor factory,
final String entityName, final String entityName,
@ -122,7 +121,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
final boolean existsInDatabase, final boolean existsInDatabase,
final boolean isBeingReplicated, final boolean isBeingReplicated,
final PersistenceContext persistenceContext) { final PersistenceContext persistenceContext) {
this.persister = ( factory == null ? null : factory.getEntityPersister( entityName ) ); this.persister = ( factory == null ? null : factory.getMetamodel().entityPersister(entityName));
this.id = id; this.id = id;
setCompressedValue( EnumState.STATUS, status ); setCompressedValue( EnumState.STATUS, status );
setCompressedValue( EnumState.PREVIOUS_STATUS, previousStatus ); setCompressedValue( EnumState.PREVIOUS_STATUS, previousStatus );
@ -328,10 +327,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor(); final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) { if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
EnhancementAsProxyLazinessInterceptor enhancementAsProxyLazinessInterceptor = (EnhancementAsProxyLazinessInterceptor) interceptor; EnhancementAsProxyLazinessInterceptor enhancementAsProxyLazinessInterceptor = (EnhancementAsProxyLazinessInterceptor) interceptor;
if ( enhancementAsProxyLazinessInterceptor.hasWrittenFieldNames() ) { return !enhancementAsProxyLazinessInterceptor.hasWrittenFieldNames();
return false;
}
return true;
} }
} }
else if ( entity instanceof HibernateProxy ) { else if ( entity instanceof HibernateProxy ) {
@ -472,10 +468,10 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
* Saves the value for the given enum property. * Saves the value for the given enum property.
* *
* @param state * @param state
* identifies the value to store * identifies the value to store
* @param value * @param value
* the value to store; The caller must make sure that it matches * the value to store; The caller must make sure that it matches
* the given identifier * the given identifier
*/ */
protected <E extends Enum<E>> void setCompressedValue(EnumState<E> state, E value) { protected <E extends Enum<E>> void setCompressedValue(EnumState<E> state, E value) {
// reset the bits for the given property to 0 // reset the bits for the given property to 0
@ -488,7 +484,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
* Gets the current value of the given enum property. * Gets the current value of the given enum property.
* *
* @param state * @param state
* identifies the value to store * identifies the value to store
* @return the current value of the specified property * @return the current value of the specified property
*/ */
protected <E extends Enum<E>> E getCompressedValue(EnumState<E> state) { protected <E extends Enum<E>> E getCompressedValue(EnumState<E> state) {
@ -501,9 +497,9 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
* Saves the value for the given boolean flag. * Saves the value for the given boolean flag.
* *
* @param state * @param state
* identifies the value to store * identifies the value to store
* @param value * @param value
* the value to store * the value to store
*/ */
protected void setCompressedValue(BooleanState state, boolean value) { protected void setCompressedValue(BooleanState state, boolean value) {
compressedState &= state.getUnsetMask(); compressedState &= state.getUnsetMask();
@ -514,7 +510,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
* Gets the current value of the given boolean flag. * Gets the current value of the given boolean flag.
* *
* @param state * @param state
* identifies the value to store * identifies the value to store
* @return the current value of the specified flag * @return the current value of the specified flag
*/ */
protected boolean getCompressedValue(BooleanState state) { protected boolean getCompressedValue(BooleanState state) {
@ -607,7 +603,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
private final int mask; private final int mask;
private final int unsetMask; private final int unsetMask;
private BooleanState(int offset) { BooleanState(int offset) {
this.offset = offset; this.offset = offset;
this.mask = 0x1 << offset; this.mask = 0x1 << offset;
this.unsetMask = 0xFFFF & ~mask; this.unsetMask = 0xFFFF & ~mask;

View File

@ -460,7 +460,7 @@ public final class Cascade {
final CascadeStyle style, final CascadeStyle style,
final Object anything, final Object anything,
final CollectionType type) { final CollectionType type) {
final CollectionPersister persister = eventSource.getFactory().getCollectionPersister( type.getRole() ); final CollectionPersister persister = eventSource.getFactory().getMetamodel().collectionPersister(type.getRole());
final Type elemType = persister.getElementType(); final Type elemType = persister.getElementType();
CascadePoint elementsCascadePoint = cascadePoint; CascadePoint elementsCascadePoint = cascadePoint;

View File

@ -13,9 +13,6 @@ import java.util.Map;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.engine.jdbc.batch.spi.BatchKey; import org.hibernate.engine.jdbc.batch.spi.BatchKey;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.internal.CoreMessageLogger;
import org.jboss.logging.Logger;
/** /**
* An implementation of {@link org.hibernate.engine.jdbc.batch.spi.Batch} which does not perform batching. It simply * An implementation of {@link org.hibernate.engine.jdbc.batch.spi.Batch} which does not perform batching. It simply
@ -24,12 +21,8 @@ import org.jboss.logging.Logger;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class NonBatchingBatch extends AbstractBatchImpl { public class NonBatchingBatch extends AbstractBatchImpl {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
NonBatchingBatch.class.getName()
);
private JdbcCoordinator jdbcCoordinator; private final JdbcCoordinator jdbcCoordinator;
protected NonBatchingBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) { protected NonBatchingBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) {
super( key, jdbcCoordinator ); super( key, jdbcCoordinator );
@ -45,7 +38,7 @@ public class NonBatchingBatch extends AbstractBatchImpl {
final PreparedStatement statement = entry.getValue(); final PreparedStatement statement = entry.getValue();
final int rowCount = jdbcCoordinator.getResultSetReturn().executeUpdate( statement ); final int rowCount = jdbcCoordinator.getResultSetReturn().executeUpdate( statement );
getKey().getExpectation().verifyOutcome( rowCount, statement, 0, statementSQL ); getKey().getExpectation().verifyOutcome( rowCount, statement, 0, statementSQL );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement ); jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement );
jdbcCoordinator.afterStatementExecution(); jdbcCoordinator.afterStatementExecution();
} }
catch ( SQLException e ) { catch ( SQLException e ) {

View File

@ -274,11 +274,11 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
} }
private void releaseResources() { private void releaseResources() {
getLogicalConnection().getResourceRegistry().releaseResources(); getLogicalConnection().getResourceRegistry().releaseResources();
} }
private boolean hasRegisteredResources() { private boolean hasRegisteredResources() {
return getLogicalConnection().getResourceRegistry().hasRegisteredResources(); return getLogicalConnection().getResourceRegistry().hasRegisteredResources();
} }
private ConnectionReleaseMode determineConnectionReleaseMode( private ConnectionReleaseMode determineConnectionReleaseMode(

View File

@ -227,7 +227,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
private void postExtract(ResultSet rs, Statement st) { private void postExtract(ResultSet rs, Statement st) {
if ( rs != null ) { if ( rs != null ) {
jdbcCoordinator.getLogicalConnection().getResourceRegistry().register( rs, st ); jdbcCoordinator.getLogicalConnection().getResourceRegistry().register( rs, st );
} }
} }

View File

@ -67,7 +67,7 @@ public final class CollectionKey implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "CollectionKey" return "CollectionKey"
+ MessageHelper.collectionInfoString( factory.getCollectionPersister( role ), key, factory ); + MessageHelper.collectionInfoString(factory.getMetamodel().collectionPersister(role), key, factory );
} }
@Override @Override

View File

@ -149,7 +149,7 @@ public final class EntityKey implements Serializable {
public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException { public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException {
final Object id = ois.readObject(); final Object id = ois.readObject();
final String entityName = (String) ois.readObject(); final String entityName = (String) ois.readObject();
final EntityPersister entityPersister = sessionFactory.getEntityPersister( entityName ); final EntityPersister entityPersister = sessionFactory.getMetamodel().entityPersister(entityName);
return new EntityKey(id, entityPersister); return new EntityKey(id, entityPersister);
} }
} }

View File

@ -1065,11 +1065,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
delegate.addEventListeners( listeners ); delegate.addEventListeners( listeners );
} }
@Override
public boolean isFlushBeforeCompletionEnabled() {
return delegate.isFlushBeforeCompletionEnabled();
}
@Override @Override
public ActionQueue getActionQueue() { public ActionQueue getActionQueue() {
return delegate.getActionQueue(); return delegate.getActionQueue();

View File

@ -25,7 +25,6 @@ import org.hibernate.StatelessSessionBuilder;
import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.CacheImplementor; import org.hibernate.cache.spi.CacheImplementor;
import org.hibernate.cfg.Settings;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver; import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
@ -202,24 +201,24 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getProperties(); return delegate.getProperties();
} }
@Override @Deprecated @Deprecated
public EntityPersister getEntityPersister(String entityName) throws MappingException { public EntityPersister getEntityPersister(String entityName) throws MappingException {
return delegate.getEntityPersister( entityName ); return delegate.getMetamodel().entityPersister(entityName);
} }
@Override @Deprecated @Deprecated
public Map<String, EntityPersister> getEntityPersisters() { public Map<String, EntityPersister> getEntityPersisters() {
return delegate.getEntityPersisters(); return delegate.getMetamodel().entityPersisters();
} }
@Override @Deprecated @Deprecated
public CollectionPersister getCollectionPersister(String role) throws MappingException { public CollectionPersister getCollectionPersister(String role) throws MappingException {
return delegate.getCollectionPersister( role ); return delegate.getMetamodel().collectionPersister(role);
} }
@Override @Deprecated @Deprecated
public Map<String, CollectionPersister> getCollectionPersisters() { public Map<String, CollectionPersister> getCollectionPersisters() {
return delegate.getCollectionPersisters(); return delegate.getMetamodel().collectionPersisters();
} }
@Override @Override
@ -232,19 +231,14 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getSqlStringGenerationContext(); return delegate.getSqlStringGenerationContext();
} }
@Override @Deprecated @Deprecated
public Dialect getDialect() {
return delegate.getJdbcServices().getDialect();
}
@Override @Deprecated
public String[] getImplementors(String className) throws MappingException { public String[] getImplementors(String className) throws MappingException {
return delegate.getImplementors( className ); return delegate.getMetamodel().getImplementors(className);
} }
@Override @Deprecated @Deprecated
public String getImportedClassName(String name) { public String getImportedClassName(String name) {
return delegate.getImportedClassName( name ); return delegate.getMetamodel().getImportedClassName(name);
} }
@Override @Override
@ -257,34 +251,14 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.bestGuessEntityName( object ); return delegate.bestGuessEntityName( object );
} }
@Override @Deprecated
public StatisticsImplementor getStatisticsImplementor() {
return delegate.getStatistics();
}
@Override @Deprecated
public SQLExceptionConverter getSQLExceptionConverter() {
return delegate.getSQLExceptionConverter();
}
@Override @Deprecated
public SqlExceptionHelper getSQLExceptionHelper() {
return delegate.getJdbcServices().getSqlExceptionHelper();
}
@Override @Deprecated
public Settings getSettings() {
return delegate.getSettings();
}
@Override @Override
public Session openTemporarySession() throws HibernateException { public Session openTemporarySession() throws HibernateException {
return delegate.openTemporarySession(); return delegate.openTemporarySession();
} }
@Override @Deprecated @Deprecated
public Set<String> getCollectionRolesByEntityParticipant(String entityName) { public Set<String> getCollectionRolesByEntityParticipant(String entityName) {
return delegate.getCollectionRolesByEntityParticipant( entityName ); return delegate.getMetamodel().getCollectionRolesByEntityParticipant(entityName);
} }
@Override @Override
@ -327,26 +301,11 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getCurrentTenantIdentifierResolver(); return delegate.getCurrentTenantIdentifierResolver();
} }
@Override @Deprecated
public Iterable<EntityNameResolver> iterateEntityNameResolvers() {
return delegate.iterateEntityNameResolvers();
}
@Override @Override
public FastSessionServices getFastSessionServices() { public FastSessionServices getFastSessionServices() {
return delegate.getFastSessionServices(); return delegate.getFastSessionServices();
} }
@Override @Deprecated
public EntityPersister locateEntityPersister(Class<?> byClass) {
return delegate.locateEntityPersister( byClass );
}
@Override @Deprecated
public EntityPersister locateEntityPersister(String byName) {
return delegate.locateEntityPersister( byName );
}
@Override @Override
public DeserializationResolver getDeserializationResolver() { public DeserializationResolver getDeserializationResolver() {
return delegate.getDeserializationResolver(); return delegate.getDeserializationResolver();
@ -392,11 +351,6 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getReference(); return delegate.getReference();
} }
@Override
public <T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass) {
return delegate.findEntityGraphsByJavaType( entityClass );
}
@Override @Override
public EntityManager createEntityManager() { public EntityManager createEntityManager() {
return delegate.createEntityManager(); return delegate.createEntityManager();
@ -446,4 +400,9 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
public WrapperOptions getWrapperOptions() { public WrapperOptions getWrapperOptions() {
return delegate.getWrapperOptions(); return delegate.getWrapperOptions();
} }
@Override
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
return delegate.findEntityGraphsByType(entityClass);
}
} }

View File

@ -7,37 +7,24 @@
package org.hibernate.engine.spi; package org.hibernate.engine.spi;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jakarta.persistence.EntityGraph;
import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EntityNameResolver;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.Metamodel;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver; import org.hibernate.SessionFactoryObserver;
import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.cache.spi.CacheImplementor; import org.hibernate.cache.spi.CacheImplementor;
import org.hibernate.cfg.Settings;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver; import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.profile.FetchProfile; import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.event.spi.EventEngine; import org.hibernate.event.spi.EventEngine;
import org.hibernate.exception.spi.SQLExceptionConverter;
import org.hibernate.graph.spi.RootGraphImplementor; import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
import org.hibernate.metamodel.MappingMetamodel; import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.RuntimeMetamodels; import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.internal.FastSessionServices; import org.hibernate.internal.FastSessionServices;
import org.hibernate.metamodel.spi.MetamodelImplementor; import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.spi.QueryEngine;
@ -50,8 +37,8 @@ import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
/** /**
* Defines the internal contract between the {@code SessionFactory} and other parts of * Defines the internal contract between the {@link SessionFactory} and the internal
* Hibernate such as implementors of {@code Type}. * implementation of Hibernate.
* *
* @see SessionFactory * @see SessionFactory
* @see org.hibernate.internal.SessionFactoryImpl * @see org.hibernate.internal.SessionFactoryImpl
@ -62,8 +49,9 @@ import org.hibernate.type.spi.TypeConfiguration;
public interface SessionFactoryImplementor public interface SessionFactoryImplementor
extends Mapping, SessionFactory, SqmCreationContext, SqlAstCreationContext, QueryParameterBindingTypeResolver { extends Mapping, SessionFactory, SqmCreationContext, SqlAstCreationContext, QueryParameterBindingTypeResolver {
/** /**
* Get the UUID for this SessionFactory. The value is generated as a {@link java.util.UUID}, but kept * Get the UUID for this SessionFactory.
* as a String. * <p>
* The value is generated as a {@link java.util.UUID}, but kept as a String.
* *
* @return The UUID for this SessionFactory. * @return The UUID for this SessionFactory.
* *
@ -150,14 +138,6 @@ public interface SessionFactoryImplementor
*/ */
CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver(); CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
/**
* @deprecated (since 5.2) use {@link #getMetamodel()} -> {@link MetamodelImplementor#getEntityNameResolvers()}
*/
@Deprecated
default Iterable<EntityNameResolver> iterateEntityNameResolvers() {
return getMetamodel().getEntityNameResolvers();
}
/** /**
* @return the FastSessionServices instance associated with this SessionFactory * @return the FastSessionServices instance associated with this SessionFactory
*/ */
@ -179,14 +159,6 @@ public interface SessionFactoryImplementor
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Deprecations // Deprecations
/**
* @deprecated (since 5.2) Just use {@link #getStatistics} (with covariant return here as {@link StatisticsImplementor}).
*/
@Deprecated
default StatisticsImplementor getStatisticsImplementor() {
return getStatistics();
}
/** /**
* Get the JdbcServices. * Get the JdbcServices.
* *
@ -194,69 +166,16 @@ public interface SessionFactoryImplementor
*/ */
JdbcServices getJdbcServices(); JdbcServices getJdbcServices();
/**
* Get the SQL dialect.
* <p/>
* Shorthand for {@code getJdbcServices().getDialect()}
*
* @return The dialect
*
* @deprecated (since 5.2) instead, use {@link JdbcServices#getDialect()}
*/
@Deprecated
default Dialect getDialect() {
return getJdbcServices().getDialect();
}
SqlStringGenerationContext getSqlStringGenerationContext(); SqlStringGenerationContext getSqlStringGenerationContext();
/**
* Retrieves the SQLExceptionConverter in effect for this SessionFactory.
*
* @return The SQLExceptionConverter for this SessionFactory.
*
* @deprecated since 5.0; use {@link JdbcServices#getSqlExceptionHelper()} ->
* {@link SqlExceptionHelper#getSqlExceptionConverter()} instead as obtained from {@link #getServiceRegistry()}
*/
@Deprecated
default SQLExceptionConverter getSQLExceptionConverter() {
return getJdbcServices().getSqlExceptionHelper().getSqlExceptionConverter();
}
/**
* Retrieves the SqlExceptionHelper in effect for this SessionFactory.
*
* @return The SqlExceptionHelper for this SessionFactory.
*
* @deprecated since 5.0; use {@link JdbcServices#getSqlExceptionHelper()} instead as
* obtained from {@link #getServiceRegistry()}
*/
@Deprecated
default SqlExceptionHelper getSQLExceptionHelper() {
return getJdbcServices().getSqlExceptionHelper();
}
/**
* @deprecated since 5.0; use {@link #getSessionFactoryOptions()} instead
*/
@Deprecated
Settings getSettings();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// map these to Metamodel // map these to Metamodel
@Override @Override
MetamodelImplementor getMetamodel(); MetamodelImplementor getMetamodel();
@SuppressWarnings({ "unchecked", "rawtypes" })
default <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
return (List) findEntityGraphsByJavaType( entityClass );
}
<T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass);
RootGraphImplementor<?> findEntityGraphByName(String name); RootGraphImplementor<?> findEntityGraphByName(String name);
/** /**
@ -264,84 +183,4 @@ public interface SessionFactoryImplementor
*/ */
String bestGuessEntityName(Object object); String bestGuessEntityName(Object object);
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#entityPersister(Class)} instead.
*/
@Deprecated
default EntityPersister getEntityPersister(String entityName) throws MappingException {
return getMetamodel().entityPersister( entityName );
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#entityPersisters} instead.
*/
@Deprecated
default Map<String,EntityPersister> getEntityPersisters() {
return getMetamodel().entityPersisters();
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#collectionPersister(String)} instead.
*/
@Deprecated
default CollectionPersister getCollectionPersister(String role) throws MappingException {
return getMetamodel().collectionPersister( role );
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#collectionPersisters} instead.
*/
@Deprecated
default Map<String, CollectionPersister> getCollectionPersisters() {
return getMetamodel().collectionPersisters();
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#collectionPersisters} instead.
* Retrieves a set of all the collection roles in which the given entity
* is a participant, as either an index or an element.
*
* @param entityName The entity name for which to get the collection roles.
* @return set of all the collection roles in which the given entityName participates.
*/
@Deprecated
default Set<String> getCollectionRolesByEntityParticipant(String entityName) {
return getMetamodel().getCollectionRolesByEntityParticipant( entityName );
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#locateEntityPersister(Class)} instead.
*/
@Deprecated
default EntityPersister locateEntityPersister(Class<?> byClass) {
return getMetamodel().locateEntityPersister( byClass );
}
/**
* @deprecated (since 5.2) Use {@link MetamodelImplementor#locateEntityPersister(String)} instead.
*/
@Deprecated
default EntityPersister locateEntityPersister(String byName) {
return getMetamodel().locateEntityPersister( byName );
}
/**
* Get the names of all persistent classes that implement/extend the given interface/class
*
* @deprecated Use {@link Metamodel#getImplementors(String)} instead
*/
@Deprecated
default String[] getImplementors(String entityName) {
return getMetamodel().getImplementors( entityName );
}
/**
* Get a class name, using query language imports
*
* @deprecated Use {@link Metamodel#getImportedClassName(String)} instead
*/
@Deprecated
default String getImportedClassName(String name) {
return getMetamodel().getImportedClassName( name );
}
} }

View File

@ -17,31 +17,33 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinator;
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
/** /**
* Defines the "internal contract" for {@link Session} and other parts of Hibernate such as * Defines the "internal contract" for {@link Session} and other parts of Hibernate such
* {@link org.hibernate.type.Type}, {@link EntityPersister} * as {@link org.hibernate.type.Type}, {@link EntityPersister}
* and {@link org.hibernate.persister.collection.CollectionPersister} implementations. * and {@link org.hibernate.persister.collection.CollectionPersister} implementations.
* *
* A Session, through this interface and SharedSessionContractImplementor, implements: * A Session, through this interface and SharedSessionContractImplementor, implements:
* <ul> * <ul>
* <li> * <li>
* {@link org.hibernate.resource.jdbc.spi.JdbcSessionOwner} to drive the behavior of the * {@link org.hibernate.resource.jdbc.spi.JdbcSessionOwner} to drive the behavior
* {@link org.hibernate.resource.jdbc.spi.JdbcSessionContext} delegate * of the {@link org.hibernate.resource.jdbc.spi.JdbcSessionContext} delegate
* </li> * </li>
* <li> * <li>
* {@link TransactionCoordinatorBuilder.Options} * {@link TransactionCoordinatorBuilder.Options}
* to drive the creation of the {@link TransactionCoordinator} delegate * to drive the creation of the {@link TransactionCoordinator} delegate
* </li> * </li>
* <li> * <li>
* {@link org.hibernate.engine.jdbc.LobCreationContext} to act as the context for JDBC LOB instance creation * {@link org.hibernate.engine.jdbc.LobCreationContext} to act as the context for
* JDBC LOB instance creation
* </li> * </li>
* <li> * <li>
* {@link org.hibernate.type.descriptor.WrapperOptions} to fulfill the behavior needed while * {@link org.hibernate.type.descriptor.WrapperOptions} to fulfill the behavior
* binding/extracting values to/from JDBC as part of the Type contracts * needed while binding/extracting values to/from JDBC as part of the {@code Type}
* contracts
* </li> * </li>
* </ul> * </ul>
* *
* See also {@link org.hibernate.event.spi.EventSource} which extends this interface providing * See also {@link org.hibernate.event.spi.EventSource} which extends this interface
* bridge to the event generation features of {@link org.hibernate.event} * providing s bridge to the event generation features of {@link org.hibernate.event}.
* *
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
@ -65,13 +67,6 @@ public interface SessionImplementor extends Session, SharedSessionContractImplem
@Override @Override
RootGraphImplementor<?> getEntityGraph(String graphName); RootGraphImplementor<?> getEntityGraph(String graphName);
/**
* @deprecated (since 5.2) use {@link #getHibernateFlushMode()} instead.
*/
@Deprecated
boolean isFlushBeforeCompletionEnabled();
ActionQueue getActionQueue(); ActionQueue getActionQueue();
Object instantiate(EntityPersister persister, Object id) throws HibernateException; Object instantiate(EntityPersister persister, Object id) throws HibernateException;
@ -79,37 +74,37 @@ public interface SessionImplementor extends Session, SharedSessionContractImplem
void forceFlush(EntityEntry e) throws HibernateException; void forceFlush(EntityEntry e) throws HibernateException;
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void merge(String entityName, Object object, Map copiedAlready) throws HibernateException; void merge(String entityName, Object object, Map copiedAlready) throws HibernateException;
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void persist(String entityName, Object object, Map createdAlready) throws HibernateException; void persist(String entityName, Object object, Map createdAlready) throws HibernateException;
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void persistOnFlush(String entityName, Object object, Map copiedAlready); void persistOnFlush(String entityName, Object object, Map copiedAlready);
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException; void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException;
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, Set transientEntities); void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, Set transientEntities);
/** /**
* @deprecated OperationalContext should cover this overload I believe; Gail? * @deprecated OperationalContext should cover this overload I believe
*/ */
@Deprecated @Deprecated
void removeOrphanBeforeUpdates(String entityName, Object child); void removeOrphanBeforeUpdates(String entityName, Object child);

View File

@ -56,7 +56,7 @@ public class DefaultEvictEventListener implements EvictEventListener {
throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" ); throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" );
} }
final EntityPersister persister = source.getFactory().getEntityPersister( li.getEntityName() ); final EntityPersister persister = source.getFactory().getMetamodel().entityPersister(li.getEntityName());
final EntityKey key = source.generateEntityKey( id, persister ); final EntityKey key = source.generateEntityKey( id, persister );
persistenceContext.removeProxy( key ); persistenceContext.removeProxy( key );
@ -82,7 +82,7 @@ public class DefaultEvictEventListener implements EvictEventListener {
final String entityName = persistenceContext.getSession().guessEntityName( object ); final String entityName = persistenceContext.getSession().guessEntityName( object );
if ( entityName != null ) { if ( entityName != null ) {
try { try {
persister = persistenceContext.getSession().getFactory().getEntityPersister( entityName ); persister = persistenceContext.getSession().getFactory().getMetamodel().entityPersister(entityName);
} }
catch (Exception ignore) { catch (Exception ignore) {
} }

View File

@ -52,7 +52,7 @@ public class DefaultPersistEventListener
* *
*/ */
public void onPersist(PersistEvent event) throws HibernateException { public void onPersist(PersistEvent event) throws HibernateException {
onPersist( event, new IdentityHashMap( 10 ) ); onPersist( event, new IdentityHashMap<>( 10 ) );
} }
/** /**
@ -103,8 +103,8 @@ public class DefaultPersistEventListener
// entity state again. // entity state again.
// NOTE: entityEntry must be null to get here, so we cannot use any of its values // NOTE: entityEntry must be null to get here, so we cannot use any of its values
EntityPersister persister = source.getFactory().getEntityPersister( entityName ); EntityPersister persister = source.getFactory().getMetamodel().entityPersister(entityName);
if ( ForeignGenerator.class.isInstance( persister.getIdentifierGenerator() ) ) { if ( persister.getIdentifierGenerator() instanceof ForeignGenerator ) {
if ( LOG.isDebugEnabled() && persister.getIdentifier( entity, source ) != null ) { if ( LOG.isDebugEnabled() && persister.getIdentifier( entity, source ) != null ) {
LOG.debug( "Resetting entity id attribute to null for foreign generator" ); LOG.debug( "Resetting entity id attribute to null for foreign generator" );
} }

View File

@ -35,7 +35,7 @@ public class OnLockVisitor extends ReattachVisitor {
} }
final SessionImplementor session = getSession(); final SessionImplementor session = getSession();
final CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() ); final CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
if ( collection instanceof PersistentCollection ) { if ( collection instanceof PersistentCollection ) {
final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) collection; final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) collection;

View File

@ -16,9 +16,9 @@ import org.hibernate.type.CollectionType;
* When an entity is passed to update(), we must inspect all its collections and * When an entity is passed to update(), we must inspect all its collections and
* 1. associate any uninitialized PersistentCollections with this session * 1. associate any uninitialized PersistentCollections with this session
* 2. associate any initialized PersistentCollections with this session, using the * 2. associate any initialized PersistentCollections with this session, using the
* existing snapshot * existing snapshot
* 3. execute a collection removal (SQL DELETE) for each null collection property * 3. execute a collection removal (SQL DELETE) for each null collection property
* or "new" collection * or "new" collection
* *
* @author Gavin King * @author Gavin King
*/ */
@ -36,7 +36,7 @@ public class OnUpdateVisitor extends ReattachVisitor {
} }
EventSource session = getSession(); EventSource session = getSession();
CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() ); CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
final Object collectionKey = extractCollectionKeyFromOwner( persister ); final Object collectionKey = extractCollectionKeyFromOwner( persister );
if ( ( collection instanceof PersistentCollection ) ) { if ( ( collection instanceof PersistentCollection ) ) {

View File

@ -61,8 +61,7 @@ public abstract class ProxyVisitor extends AbstractVisitor {
throws HibernateException { throws HibernateException {
final EventSource session = getSession(); final EventSource session = getSession();
if ( collection.wasInitialized() ) { if ( collection.wasInitialized() ) {
CollectionPersister collectionPersister = session.getFactory() CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
.getCollectionPersister( type.getRole() );
session.getPersistenceContext() session.getPersistenceContext()
.addInitializedDetachedCollection( collectionPersister, collection ); .addInitializedDetachedCollection( collectionPersister, collection );
} }
@ -70,8 +69,7 @@ public abstract class ProxyVisitor extends AbstractVisitor {
if ( !isCollectionSnapshotValid( collection ) ) { if ( !isCollectionSnapshotValid( collection ) ) {
throw new HibernateException( "could not re-associate uninitialized transient collection" ); throw new HibernateException( "could not re-associate uninitialized transient collection" );
} }
CollectionPersister collectionPersister = session.getFactory() CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister(collection.getRole());
.getCollectionPersister( collection.getRole() );
session.getPersistenceContext() session.getPersistenceContext()
.addUninitializedDetachedCollection( collectionPersister, collection ); .addUninitializedDetachedCollection( collectionPersister, collection );
} }

View File

@ -80,7 +80,7 @@ public class WrapVisitor extends ProxyVisitor {
return null; return null;
} }
else { else {
CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() ); CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(collectionType.getRole());
final PersistenceContext persistenceContext = session.getPersistenceContextInternal(); final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
//TODO: move into collection type, so we can use polymorphism! //TODO: move into collection type, so we can use polymorphism!

View File

@ -75,7 +75,7 @@ public class FilterConfiguration {
} }
if ( aliasEntityMap != null ) { if ( aliasEntityMap != null ) {
for ( Map.Entry<String, String> entry : aliasEntityMap.entrySet() ) { for ( Map.Entry<String, String> entry : aliasEntityMap.entrySet() ) {
Joinable joinable = (Joinable) factory.getEntityPersister( entry.getValue() ); Joinable joinable = (Joinable) factory.getMetamodel().entityPersister(entry.getValue());
ret.put( entry.getKey(), joinable.getTableName() ); ret.put( entry.getKey(), joinable.getTableName() );
} }
} }

View File

@ -607,18 +607,11 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
); );
} }
@SuppressWarnings("deprecation")
public Settings getSettings() {
return settings;
}
@Override @Override
public <T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass) { public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
return getMetamodel().findEntityGraphsByJavaType( entityClass ); return (List) getMetamodel().findEntityGraphsByJavaType( entityClass );
} }
// todo : (5.2) review synchronizationType, persistenceContextType, transactionType usage // todo : (5.2) review synchronizationType, persistenceContextType, transactionType usage
// SynchronizationType -> should we auto enlist in transactions // SynchronizationType -> should we auto enlist in transactions
@ -708,7 +701,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
@Override @Override
public RootGraphImplementor findEntityGraphByName(String name) { public RootGraphImplementor<?> findEntityGraphByName(String name) {
return getMetamodel().findEntityGraphByName( name ); return getMetamodel().findEntityGraphByName( name );
} }
@ -1027,29 +1020,27 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
} }
if ( "jta".equals( impl ) ) { switch (impl) {
case "jta":
// if ( ! transactionFactory().compatibleWithJtaSynchronization() ) { // if ( ! transactionFactory().compatibleWithJtaSynchronization() ) {
// LOG.autoFlushWillNotWork(); // LOG.autoFlushWillNotWork();
// } // }
return new JTASessionContext( this ); return new JTASessionContext(this);
} case "thread":
else if ( "thread".equals( impl ) ) { return new ThreadLocalSessionContext(this);
return new ThreadLocalSessionContext( this ); case "managed":
} return new ManagedSessionContext(this);
else if ( "managed".equals( impl ) ) { default:
return new ManagedSessionContext( this ); try {
} Class<?> implClass = serviceRegistry.getService(ClassLoaderService.class).classForName(impl);
else { return (CurrentSessionContext)
try { implClass.getConstructor( new Class[]{SessionFactoryImplementor.class} )
Class implClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( impl ); .newInstance(this);
return (CurrentSessionContext) }
implClass.getConstructor( new Class[] { SessionFactoryImplementor.class } ) catch (Throwable t) {
.newInstance( this ); LOG.unableToConstructCurrentSessionContext(impl, t);
} return null;
catch( Throwable t ) { }
LOG.unableToConstructCurrentSessionContext( impl, t );
return null;
}
} }
} }
@ -1149,7 +1140,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
else if ( statelessInterceptorImplementor != null ) { else if ( statelessInterceptorImplementor != null ) {
try { try {
/** /*
* We could remove the getStatelessInterceptorImplementor method and use just the getStatelessInterceptorImplementorSupplier * We could remove the getStatelessInterceptorImplementor method and use just the getStatelessInterceptorImplementorSupplier
* since it can cover both cases when the user has given a Supplier<? extends Interceptor> or just the * since it can cover both cases when the user has given a Supplier<? extends Interceptor> or just the
* Class<? extends Interceptor>, in which case, we simply instantiate the Interceptor when calling the Supplier. * Class<? extends Interceptor>, in which case, we simply instantiate the Interceptor when calling the Supplier.
@ -1302,7 +1293,6 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
} }
@Override @Override
@SuppressWarnings("unchecked")
public T owner(SessionOwner sessionOwner) { public T owner(SessionOwner sessionOwner) {
throw new UnsupportedOperationException( "SessionOwner was long deprecated and this method should no longer be invoked" ); throw new UnsupportedOperationException( "SessionOwner was long deprecated and this method should no longer be invoked" );
} }
@ -1418,7 +1408,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
return (T) this; return (T) this;
} }
@Override @Override @SuppressWarnings("unchecked")
public T jdbcTimeZone(TimeZone timeZone) { public T jdbcTimeZone(TimeZone timeZone) {
jdbcTimeZone = timeZone; jdbcTimeZone = timeZone;
return (T) this; return (T) this;
@ -1684,6 +1674,6 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
private enum Status { private enum Status {
OPEN, OPEN,
CLOSING, CLOSING,
CLOSED; CLOSED
} }
} }

View File

@ -2190,11 +2190,6 @@ public class SessionImpl
return status == TransactionStatus.ACTIVE || status == TransactionStatus.COMMITTING; return status == TransactionStatus.ACTIVE || status == TransactionStatus.COMMITTING;
} }
@Override
public boolean isFlushBeforeCompletionEnabled() {
return getHibernateFlushMode() != FlushMode.MANUAL;
}
@Override @Override
public SessionImplementor getSession() { public SessionImplementor getSession() {
return this; return this;

View File

@ -39,7 +39,7 @@ public final class EntityPrinter {
* @return the entity rendered to a string * @return the entity rendered to a string
*/ */
public String toString(String entityName, Object entity) throws HibernateException { public String toString(String entityName, Object entity) throws HibernateException {
EntityPersister entityPersister = factory.getEntityPersister( entityName ); EntityPersister entityPersister = factory.getMetamodel().entityPersister(entityName);
if ( entityPersister == null || !entityPersister.isInstance( entity ) ) { if ( entityPersister == null || !entityPersister.isInstance( entity ) ) {
return entity.getClass().getName(); return entity.getClass().getName();

View File

@ -141,8 +141,7 @@ public class CacheEntityLoaderHelper {
} }
if ( options.isAllowNulls() ) { if ( options.isAllowNulls() ) {
final EntityPersister persister = event.getSession() final EntityPersister persister = event.getSession()
.getFactory() .getFactory().getMetamodel().entityPersister(keyToLoad.getEntityName());
.getEntityPersister( keyToLoad.getEntityName() );
if ( !persister.isInstance( old ) ) { if ( !persister.isInstance( old ) ) {
LOG.debug( LOG.debug(
"Load request found matching entity in context, but the matched entity was of an inconsistent return type; returning null" "Load request found matching entity in context, but the matched entity was of an inconsistent return type; returning null"
@ -366,7 +365,7 @@ public class CacheEntityLoaderHelper {
final Object entity; final Object entity;
subclassPersister = factory.getEntityPersister( entry.getSubclass() ); subclassPersister = factory.getMetamodel().entityPersister(entry.getSubclass());
entity = instanceToLoad == null entity = instanceToLoad == null
? source.instantiate( subclassPersister, entityId ) ? source.instantiate( subclassPersister, entityId )
: instanceToLoad; : instanceToLoad;

View File

@ -276,7 +276,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
} }
finally { finally {
if ( !useBatch ) { if ( !useBatch ) {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st ); session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution(); session.getJdbcCoordinator().afterStatementExecution();
} }
} }
@ -389,7 +389,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
} }
finally { finally {
if ( !useBatch ) { if ( !useBatch ) {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st ); session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution(); session.getJdbcCoordinator().afterStatementExecution();
} }
} }
@ -461,7 +461,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
} }
finally { finally {
if ( !useBatch ) { if ( !useBatch ) {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st ); session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution(); session.getJdbcCoordinator().afterStatementExecution();
} }
} }

View File

@ -134,7 +134,7 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T>,
int index, int index,
SharedSessionContractImplementor session) throws HibernateException, SQLException { SharedSessionContractImplementor session) throws HibernateException, SQLException {
String entityName = session.getFactory().getClassMetadata((Class) value).getEntityName(); String entityName = session.getFactory().getClassMetadata((Class) value).getEntityName();
Loadable entityPersister = (Loadable) session.getFactory().getEntityPersister(entityName); Loadable entityPersister = (Loadable) session.getFactory().getMetamodel().entityPersister(entityName);
underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session); underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session);
} }
@ -142,7 +142,7 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T>,
public void bind(PreparedStatement st, T value, int index, WrapperOptions options) throws SQLException { public void bind(PreparedStatement st, T value, int index, WrapperOptions options) throws SQLException {
final SessionFactoryImplementor factory = options.getSession().getFactory(); final SessionFactoryImplementor factory = options.getSession().getFactory();
final String entityName = factory.getClassMetadata( (Class) value).getEntityName(); final String entityName = factory.getClassMetadata( (Class) value).getEntityName();
final Loadable entityPersister = (Loadable) factory.getEntityPersister( entityName); final Loadable entityPersister = (Loadable) factory.getMetamodel().entityPersister(entityName);
underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), index, options ); underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), index, options );
} }
@ -150,7 +150,7 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T>,
public void bind(CallableStatement st, T value, String name, WrapperOptions options) throws SQLException { public void bind(CallableStatement st, T value, String name, WrapperOptions options) throws SQLException {
final SessionFactoryImplementor factory = options.getSession().getFactory(); final SessionFactoryImplementor factory = options.getSession().getFactory();
final String entityName = factory.getClassMetadata( (Class) value).getEntityName(); final String entityName = factory.getClassMetadata( (Class) value).getEntityName();
final Loadable entityPersister = (Loadable) factory.getEntityPersister( entityName); final Loadable entityPersister = (Loadable) factory.getMetamodel().entityPersister(entityName);
underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), name, options ); underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), name, options );
} }

View File

@ -175,8 +175,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
} }
else { else {
final Column column = (Column) selectable; final Column column = (Column) selectable;
explicitDiscriminatorColumnName = column.getQuotedName(factory.getJdbcServices().getDialect()); explicitDiscriminatorColumnName = column.getQuotedName(factory.getJdbcServices().getDialect());
discriminatorAlias = column.getAlias(factory.getJdbcServices().getDialect(), persistentClass.getRootTable() ); discriminatorAlias = column.getAlias(factory.getJdbcServices().getDialect(), persistentClass.getRootTable() );
} }
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType(); discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
if ( persistentClass.isDiscriminatorValueNull() ) { if ( persistentClass.isDiscriminatorValueNull() ) {
@ -646,16 +646,16 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
* <p/> * <p/>
* For the persister for JoinedEntity, we'd have: * For the persister for JoinedEntity, we'd have:
* <pre> * <pre>
* subclassClosure[0] = "JoinedEntitySubSubclass" * subclassClosure[0] = "JoinedEntitySubSubclass"
* subclassClosure[1] = "JoinedEntitySubclass" * subclassClosure[1] = "JoinedEntitySubclass"
* subclassClosure[2] = "JoinedEntity" * subclassClosure[2] = "JoinedEntity"
* *
* subclassTableNameClosure[0] = "T_JoinedEntity" * subclassTableNameClosure[0] = "T_JoinedEntity"
* subclassTableNameClosure[1] = "T_JoinedEntitySubclass" * subclassTableNameClosure[1] = "T_JoinedEntitySubclass"
* subclassTableNameClosure[2] = "T_JoinedEntitySubSubclass" * subclassTableNameClosure[2] = "T_JoinedEntitySubSubclass"
* *
* subclassNameClosureBySubclassTable[0] = ["JoinedEntitySubSubclass", "JoinedEntitySubclass"] * subclassNameClosureBySubclassTable[0] = ["JoinedEntitySubSubclass", "JoinedEntitySubclass"]
* subclassNameClosureBySubclassTable[1] = ["JoinedEntitySubSubclass"] * subclassNameClosureBySubclassTable[1] = ["JoinedEntitySubSubclass"]
* </pre> * </pre>
* Note that there are only 2 entries in subclassNameClosureBySubclassTable. That is because there are really only * Note that there are only 2 entries in subclassNameClosureBySubclassTable. That is because there are really only
* 2 tables here that make up the subclass mapping, the others make up the class/superclass table mappings. We * 2 tables here that make up the subclass mapping, the others make up the class/superclass table mappings. We

View File

@ -135,7 +135,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
session = s; session = s;
if ( readOnlyBeforeAttachedToSession == null ) { if ( readOnlyBeforeAttachedToSession == null ) {
// use the default read-only/modifiable setting // use the default read-only/modifiable setting
final EntityPersister persister = s.getFactory().getEntityPersister( entityName ); final EntityPersister persister = s.getFactory().getMetamodel().entityPersister(entityName);
setReadOnly( s.getPersistenceContext().isDefaultReadOnly() || !persister.isMutable() ); setReadOnly( s.getPersistenceContext().isDefaultReadOnly() || !persister.isMutable() );
} }
else { else {
@ -151,7 +151,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
if ( id == null || s == null || entityName == null ) { if ( id == null || s == null || entityName == null ) {
return null; return null;
} }
return s.generateEntityKey( id, s.getFactory().getEntityPersister( entityName ) ); return s.generateEntityKey( id, s.getFactory().getMetamodel().entityPersister(entityName));
} }
@Override @Override
@ -371,7 +371,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
errorIfReadOnlySettingNotAvailable(); errorIfReadOnlySettingNotAvailable();
// only update if readOnly is different from current setting // only update if readOnly is different from current setting
if ( this.readOnly != readOnly ) { if ( this.readOnly != readOnly ) {
final EntityPersister persister = session.getFactory().getEntityPersister( entityName ); final EntityPersister persister = session.getFactory().getMetamodel().entityPersister(entityName);
if ( !persister.isMutable() && !readOnly ) { if ( !persister.isMutable() && !readOnly ) {
throw new IllegalStateException( "cannot make proxies [" + entityName + "#" + id + "] for immutable entities modifiable" ); throw new IllegalStateException( "cannot make proxies [" + entityName + "#" + id + "] for immutable entities modifiable" );
} }
@ -394,8 +394,8 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
* is not available (i.e., isReadOnlySettingAvailable() == false) * is not available (i.e., isReadOnlySettingAvailable() == false)
* *
* @return null, if the default setting should be used; * @return null, if the default setting should be used;
* true, for read-only; * true, for read-only;
* false, for modifiable * false, for modifiable
* *
* @throws IllegalStateException if isReadOnlySettingAvailable() == true * @throws IllegalStateException if isReadOnlySettingAvailable() == true
*/ */

View File

@ -384,7 +384,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
} }
private SQLLoadable getSQLLoadable(String entityName) throws MappingException { private SQLLoadable getSQLLoadable(String entityName) throws MappingException {
EntityPersister persister = factory.getEntityPersister( entityName ); EntityPersister persister = factory.getMetamodel().entityPersister(entityName);
if ( !(persister instanceof SQLLoadable) ) { if ( !(persister instanceof SQLLoadable) ) {
throw new MappingException( "class persister is not SQLLoadable: " + entityName ); throw new MappingException( "class persister is not SQLLoadable: " + entityName );
} }
@ -450,7 +450,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
} }
private void addCollection(String role, String alias, Map<String, String[]> propertyResults) { private void addCollection(String role, String alias, Map<String, String[]> propertyResults) {
SQLLoadableCollection collectionPersister = ( SQLLoadableCollection ) factory.getCollectionPersister( role ); SQLLoadableCollection collectionPersister = ( SQLLoadableCollection ) factory.getMetamodel().collectionPersister(role);
alias2CollectionPersister.put( alias, collectionPersister ); alias2CollectionPersister.put( alias, collectionPersister );
String suffix = generateCollectionSuffix(); String suffix = generateCollectionSuffix();
LOG.tracev( "Mapping alias [{0}] to collection-suffix [{1}]", alias, suffix ); LOG.tracev( "Mapping alias [{0}] to collection-suffix [{1}]", alias, suffix );

View File

@ -469,7 +469,7 @@ public abstract class CollectionType extends AbstractType implements Association
@Override @Override
public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) public Joinable getAssociatedJoinable(SessionFactoryImplementor factory)
throws MappingException { throws MappingException {
return (Joinable) factory.getCollectionPersister( role ); return (Joinable) factory.getMetamodel().collectionPersister(role);
} }
@Override @Override
@ -482,8 +482,7 @@ public abstract class CollectionType extends AbstractType implements Association
throws MappingException { throws MappingException {
try { try {
QueryableCollection collectionPersister = (QueryableCollection) factory QueryableCollection collectionPersister = (QueryableCollection) factory.getMetamodel().collectionPersister(role);
.getCollectionPersister( role );
if ( !collectionPersister.getElementType().isEntityType() ) { if ( !collectionPersister.getElementType().isEntityType() ) {
throw new MappingException( throw new MappingException(
@ -716,7 +715,7 @@ public abstract class CollectionType extends AbstractType implements Association
* @throws MappingException Indicates the underlying persister could not be located. * @throws MappingException Indicates the underlying persister could not be located.
*/ */
public final Type getElementType(SessionFactoryImplementor factory) throws MappingException { public final Type getElementType(SessionFactoryImplementor factory) throws MappingException {
return factory.getCollectionPersister( getRole() ).getElementType(); return factory.getMetamodel().collectionPersister(getRole()).getElementType();
} }
@Override @Override

View File

@ -52,14 +52,14 @@ public class EntityNonEntityTest extends BaseCoreFunctionalTestCase {
@TestForIssue( jiraKey = "HHH-9856" ) @TestForIssue( jiraKey = "HHH-9856" )
public void testGetAndFindNonEntityThrowsIllegalArgumentException() { public void testGetAndFindNonEntityThrowsIllegalArgumentException() {
try { try {
sessionFactory().locateEntityPersister( Cellular.class ); sessionFactory().getMetamodel().locateEntityPersister(Cellular.class);
} }
catch (UnknownEntityTypeException ignore) { catch (UnknownEntityTypeException ignore) {
// expected // expected
} }
try { try {
sessionFactory().locateEntityPersister( Cellular.class.getName() ); sessionFactory().getMetamodel().locateEntityPersister(Cellular.class.getName());
} }
catch (UnknownEntityTypeException ignore) { catch (UnknownEntityTypeException ignore) {
// expected // expected

View File

@ -77,7 +77,7 @@ public class EnumeratedWithMappedSuperclassTest extends BaseUnitTestCase {
SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory(); SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory();
try { try {
EntityPersister p = sf.getEntityPersister( AddressLevel.class.getName() ); EntityPersister p = sf.getMetamodel().entityPersister(AddressLevel.class.getName());
CustomType<Object> runtimeType = assertTyping( CustomType.class, p.getPropertyType( "nature" ) ); CustomType<Object> runtimeType = assertTyping( CustomType.class, p.getPropertyType( "nature" ) );
EnumType runtimeEnumType = assertTyping( EnumType.class, runtimeType.getUserType() ); EnumType runtimeEnumType = assertTyping( EnumType.class, runtimeType.getUserType() );
assertEquals( Types.VARCHAR, runtimeEnumType.sqlTypes()[0] ); assertEquals( Types.VARCHAR, runtimeEnumType.sqlTypes()[0] );

View File

@ -56,7 +56,7 @@ public class NewGeneratorMappingsTest {
@Test @Test
public void testMinimalSequenceEntity(SessionFactoryScope scope) { public void testMinimalSequenceEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( MinimalSequenceEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(MinimalSequenceEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -71,7 +71,7 @@ public class NewGeneratorMappingsTest {
@Test @Test
public void testCompleteSequenceEntity(SessionFactoryScope scope) { public void testCompleteSequenceEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( CompleteSequenceEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(CompleteSequenceEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -82,7 +82,7 @@ public class NewGeneratorMappingsTest {
@Test @Test
public void testAutoEntity(SessionFactoryScope scope) { public void testAutoEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( AutoEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(AutoEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -93,7 +93,7 @@ public class NewGeneratorMappingsTest {
@Test @Test
public void testTablePerClassAutoEntity(SessionFactoryScope scope) { public void testTablePerClassAutoEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( AbstractTPCAutoEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(AbstractTPCAutoEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -105,7 +105,7 @@ public class NewGeneratorMappingsTest {
@Test @Test
public void testMinimalTableEntity(SessionFactoryScope scope) { public void testMinimalTableEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( MinimalTableEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(MinimalTableEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( TableGenerator.class.isInstance( generator ) ); assertTrue( TableGenerator.class.isInstance( generator ) );
TableGenerator tabGenerator = (TableGenerator) generator; TableGenerator tabGenerator = (TableGenerator) generator;
@ -124,7 +124,7 @@ public class NewGeneratorMappingsTest {
@TestForIssue(jiraKey = "HHH-6790") @TestForIssue(jiraKey = "HHH-6790")
public void testSequencePerEntity(SessionFactoryScope scope) { public void testSequencePerEntity(SessionFactoryScope scope) {
// Checking first entity. // Checking first entity.
EntityPersister persister = scope.getSessionFactory().getEntityPersister( DedicatedSequenceEntity1.class.getName() ); EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(DedicatedSequenceEntity1.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
@ -134,7 +134,7 @@ public class NewGeneratorMappingsTest {
); );
// Checking second entity. // Checking second entity.
persister = scope.getSessionFactory().getEntityPersister( DedicatedSequenceEntity2.class.getName() ); persister = scope.getSessionFactory().getMetamodel().entityPersister(DedicatedSequenceEntity2.class.getName());
generator = persister.getIdentifierGenerator(); generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
seqGenerator = (SequenceStyleGenerator) generator; seqGenerator = (SequenceStyleGenerator) generator;

View File

@ -41,8 +41,7 @@ public class HibernateSequenceTest {
@Test @Test
public void testHibernateSequenceSchema(SessionFactoryScope scope) { public void testHibernateSequenceSchema(SessionFactoryScope scope) {
EntityPersister persister = scope.getSessionFactory() EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(HibernateSequenceEntity.class.getName());
.getEntityPersister( HibernateSequenceEntity.class.getName() );
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) ); assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator; SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;

View File

@ -33,8 +33,8 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testTypeSelection() { public void testTypeSelection() {
int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" ); int index = sessionFactory().getMetamodel().entityPersister(MaterializedBlobEntity.class.getName()).getEntityMetamodel().getPropertyIndex( "theBytes" );
BasicType<?> type = (BasicType<?>) sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType(); BasicType<?> type = (BasicType<?>) sessionFactory().getMetamodel().entityPersister(MaterializedBlobEntity.class.getName()).getEntityMetamodel().getProperties()[index].getType();
assertTrue( type.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType ); assertTrue( type.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType );
assertTrue( type.getJdbcType() instanceof BlobJdbcType ); assertTrue( type.getJdbcType() instanceof BlobJdbcType );
} }

View File

@ -275,8 +275,7 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
@Test @Test
@TestForIssue(jiraKey = "HHH-5732") @TestForIssue(jiraKey = "HHH-5732")
public void testInverseIndex() { public void testInverseIndex() {
final CollectionPersister transactionsPersister = sessionFactory().getCollectionPersister( final CollectionPersister transactionsPersister = sessionFactory().getMetamodel().collectionPersister(BankAccount.class.getName() + ".transactions");
BankAccount.class.getName() + ".transactions" );
assertTrue( transactionsPersister.isInverse() ); assertTrue( transactionsPersister.isInverse() );
Session s = openSession(); Session s = openSession();

View File

@ -73,7 +73,7 @@ public class QualifiedTableNamingTest extends BaseNonConfigCoreFunctionalTestCas
assertNotNull( expectedName ); assertNotNull( expectedName );
SingleTableEntityPersister persister = (SingleTableEntityPersister) sessionFactory().getEntityPersister( Box.class.getName() ); SingleTableEntityPersister persister = (SingleTableEntityPersister) sessionFactory().getMetamodel().entityPersister(Box.class.getName());
assertEquals( expectedName, persister.getTableName() ); assertEquals( expectedName, persister.getTableName() );
} }

View File

@ -12,20 +12,6 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl; import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Animal;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Being;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course1;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course2;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course3;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course4;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course5;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course6;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course7;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Course8;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Horse;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Person;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.Student;
import org.hibernate.orm.test.bootstrap.binding.annotations.access.jpa.User;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.property.access.spi.GetterFieldImpl; import org.hibernate.property.access.spi.GetterFieldImpl;
import org.hibernate.property.access.spi.GetterMethodImpl; import org.hibernate.property.access.spi.GetterMethodImpl;
@ -90,7 +76,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Student.class ); cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -111,7 +97,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Student.class ); cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -132,7 +118,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Student.class ); cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -173,7 +159,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Student.class ); cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -199,7 +185,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Student.class ); cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -226,7 +212,7 @@ public class AccessMappingTest {
cfg.addAnnotatedClass( Being.class ); cfg.addAnnotatedClass( Being.class );
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
final EntityPersister entityPersister = factory.getEntityPersister( classUnderTest.getName() ); final EntityPersister entityPersister = factory.getMetamodel().entityPersister(classUnderTest.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -247,7 +233,7 @@ public class AccessMappingTest {
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
try { try {
EntityPersister entityPersister = factory.getEntityPersister( Animal.class.getName() ); EntityPersister entityPersister = factory.getMetamodel().entityPersister(Animal.class.getName());
final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping(); final BasicEntityIdentifierMappingImpl identifierMapping = (BasicEntityIdentifierMappingImpl) entityPersister.getIdentifierMapping();
assertTrue( assertTrue(
@ -255,7 +241,7 @@ public class AccessMappingTest {
identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl identifierMapping.getPropertyAccess().getGetter() instanceof GetterMethodImpl
); );
entityPersister = factory.getEntityPersister( Horse.class.getName() ); entityPersister = factory.getMetamodel().entityPersister(Horse.class.getName());
assertTrue( assertTrue(
"Field access should be used since the default access mode gets inherited", "Field access should be used since the default access mode gets inherited",

View File

@ -89,7 +89,7 @@ public class CollectionCacheEvictionTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testCachedValueAfterEviction() { public void testCachedValueAfterEviction() {
CollectionPersister persister = sessionFactory().getCollectionPersister( Company.class.getName() + ".users" ); CollectionPersister persister = sessionFactory().getMetamodel().collectionPersister(Company.class.getName() + ".users");
Session session = openSession(); Session session = openSession();
SessionImplementor sessionImplementor = (SessionImplementor) session; SessionImplementor sessionImplementor = (SessionImplementor) session;

View File

@ -96,8 +96,8 @@ public class UnversionedCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -177,8 +177,8 @@ public class UnversionedCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManies ); assertNotNull( ceManies );
assertEquals( role, ceManies.getRole() ); assertEquals( role, ceManies.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManies.getLoadedPersister() ceManies.getLoadedPersister()
); );
assertEquals( one.getId(), ceManies.getKey() ); assertEquals( one.getId(), ceManies.getKey() );
@ -261,8 +261,8 @@ public class UnversionedCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -304,8 +304,8 @@ public class UnversionedCascadeDereferencedCollectionTest extends AbstractDerefe
); );
assertNotNull( ceManiesAfterReplace ); assertNotNull( ceManiesAfterReplace );
assertEquals( role, ceManiesAfterReplace.getRole() ); assertEquals( role, ceManiesAfterReplace.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesAfterReplace.getLoadedPersister() ceManiesAfterReplace.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesAfterReplace.getKey() ); assertEquals( one.getId(), ceManiesAfterReplace.getKey() );

View File

@ -94,8 +94,8 @@ public class UnversionedNoCascadeDereferencedCollectionTest extends AbstractDere
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -174,8 +174,8 @@ public class UnversionedNoCascadeDereferencedCollectionTest extends AbstractDere
CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManies ); assertNotNull( ceManies );
assertEquals( role, ceManies.getRole() ); assertEquals( role, ceManies.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManies.getLoadedPersister() ceManies.getLoadedPersister()
); );
assertEquals( one.getId(), ceManies.getKey() ); assertEquals( one.getId(), ceManies.getKey() );
@ -257,8 +257,8 @@ public class UnversionedNoCascadeDereferencedCollectionTest extends AbstractDere
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -300,8 +300,8 @@ public class UnversionedNoCascadeDereferencedCollectionTest extends AbstractDere
); );
assertNotNull( ceManiesAfterReplace ); assertNotNull( ceManiesAfterReplace );
assertEquals( role, ceManiesAfterReplace.getRole() ); assertEquals( role, ceManiesAfterReplace.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesAfterReplace.getLoadedPersister() ceManiesAfterReplace.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesAfterReplace.getKey() ); assertEquals( one.getId(), ceManiesAfterReplace.getKey() );

View File

@ -96,8 +96,8 @@ public class VersionedCascadeDereferencedCollectionTest extends AbstractDerefere
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -174,8 +174,8 @@ public class VersionedCascadeDereferencedCollectionTest extends AbstractDerefere
CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManies ); assertNotNull( ceManies );
assertEquals( role, ceManies.getRole() ); assertEquals( role, ceManies.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManies.getLoadedPersister() ceManies.getLoadedPersister()
); );
assertEquals( one.getId(), ceManies.getKey() ); assertEquals( one.getId(), ceManies.getKey() );
@ -254,8 +254,8 @@ public class VersionedCascadeDereferencedCollectionTest extends AbstractDerefere
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -297,8 +297,8 @@ public class VersionedCascadeDereferencedCollectionTest extends AbstractDerefere
); );
assertNotNull( ceManiesAfterReplace ); assertNotNull( ceManiesAfterReplace );
assertEquals( role, ceManiesAfterReplace.getRole() ); assertEquals( role, ceManiesAfterReplace.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesAfterReplace.getLoadedPersister() ceManiesAfterReplace.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesAfterReplace.getKey() ); assertEquals( one.getId(), ceManiesAfterReplace.getKey() );

View File

@ -96,8 +96,8 @@ public class VersionedNoCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -176,8 +176,8 @@ public class VersionedNoCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManies = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManies ); assertNotNull( ceManies );
assertEquals( role, ceManies.getRole() ); assertEquals( role, ceManies.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManies.getLoadedPersister() ceManies.getLoadedPersister()
); );
assertEquals( one.getId(), ceManies.getKey() ); assertEquals( one.getId(), ceManies.getKey() );
@ -260,8 +260,8 @@ public class VersionedNoCascadeDereferencedCollectionTest extends AbstractDerefe
CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig ); CollectionEntry ceManiesOrig = getCollectionEntry( session, maniesEEOneStateOrig );
assertNotNull( ceManiesOrig ); assertNotNull( ceManiesOrig );
assertEquals( role, ceManiesOrig.getRole() ); assertEquals( role, ceManiesOrig.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesOrig.getLoadedPersister() ceManiesOrig.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesOrig.getKey() ); assertEquals( one.getId(), ceManiesOrig.getKey() );
@ -303,8 +303,8 @@ public class VersionedNoCascadeDereferencedCollectionTest extends AbstractDerefe
); );
assertNotNull( ceManiesAfterReplace ); assertNotNull( ceManiesAfterReplace );
assertEquals( role, ceManiesAfterReplace.getRole() ); assertEquals( role, ceManiesAfterReplace.getRole() );
assertSame( assertSame(
scope.getSessionFactory().getCollectionPersister( role ), scope.getSessionFactory().getMetamodel().collectionPersister(role),
ceManiesAfterReplace.getLoadedPersister() ceManiesAfterReplace.getLoadedPersister()
); );
assertEquals( one.getId(), ceManiesAfterReplace.getKey() ); assertEquals( one.getId(), ceManiesAfterReplace.getKey() );

View File

@ -45,8 +45,7 @@ public class PersistentListTest {
public void testInverseListIndex(SessionFactoryScope scope) { public void testInverseListIndex(SessionFactoryScope scope) {
// make sure no one changes the mapping // make sure no one changes the mapping
SessionFactoryImplementor sessionFactory = scope.getSessionFactory(); SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final CollectionPersister collectionPersister = sessionFactory final CollectionPersister collectionPersister = sessionFactory.getMetamodel().collectionPersister(ListOwner.class.getName() + ".children");
.getCollectionPersister( ListOwner.class.getName() + ".children" );
assertTrue( collectionPersister.isInverse() ); assertTrue( collectionPersister.isInverse() );
// do some creations... // do some creations...
@ -110,8 +109,7 @@ public class PersistentListTest {
public void testInverseListIndex2(SessionFactoryScope scope) { public void testInverseListIndex2(SessionFactoryScope scope) {
// make sure no one changes the mapping // make sure no one changes the mapping
SessionFactoryImplementor sessionFactory = scope.getSessionFactory(); SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final CollectionPersister collectionPersister = sessionFactory final CollectionPersister collectionPersister = sessionFactory.getMetamodel().collectionPersister(Order.class.getName() + ".lineItems");
.getCollectionPersister( Order.class.getName() + ".lineItems" );
assertTrue( collectionPersister.isInverse() ); assertTrue( collectionPersister.isInverse() );
// do some creations... // do some creations...

View File

@ -172,13 +172,13 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -168,13 +168,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -90,13 +90,13 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister( entityClass.getName() ); OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getMetamodel().entityPersister(entityClass.getName());
int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path ); int index = ( (UniqueKeyLoadable) entityPersister ).getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -106,7 +106,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
@Test @Test
public void testSecondLevelCachedCollectionsFiltering() { public void testSecondLevelCachedCollectionsFiltering() {
CollectionPersister persister = sessionFactory().getCollectionPersister( Salesperson.class.getName() + ".orders" ); CollectionPersister persister = sessionFactory().getMetamodel().collectionPersister(Salesperson.class.getName() + ".orders");
CollectionDataAccess cache = persister.getCacheAccessStrategy(); CollectionDataAccess cache = persister.getCacheAccessStrategy();
CollectionCacheEntry cachedData = fromSession( CollectionCacheEntry cachedData = fromSession(

View File

@ -523,7 +523,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
} }
protected boolean supportsBulkInsertIdGeneration(Class entityClass) { protected boolean supportsBulkInsertIdGeneration(Class entityClass) {
EntityPersister persister = sessionFactory().getEntityPersister( entityClass.getName() ); EntityPersister persister = sessionFactory().getMetamodel().entityPersister(entityClass.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
return BulkInsertionCapableIdentifierGenerator.class.isInstance( generator ) return BulkInsertionCapableIdentifierGenerator.class.isInstance( generator )
&& BulkInsertionCapableIdentifierGenerator.class.cast( generator ) && BulkInsertionCapableIdentifierGenerator.class.cast( generator )

View File

@ -7,7 +7,6 @@
package org.hibernate.orm.test.idgen.enhanced.forcedtable; package org.hibernate.orm.test.idgen.enhanced.forcedtable;
import org.hibernate.Session;
import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder; import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder;
import org.hibernate.id.enhanced.NoopOptimizer; import org.hibernate.id.enhanced.NoopOptimizer;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
@ -34,7 +33,7 @@ public class BasicForcedTableSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator();

View File

@ -30,7 +30,7 @@ public class HiLoForcedTableSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();

View File

@ -30,7 +30,7 @@ public class PooledForcedTableSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.orm.test.idgen.enhanced.sequence; package org.hibernate.orm.test.idgen.enhanced.sequence;
import org.hibernate.Session;
import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder; import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
@ -20,7 +19,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
@ -39,7 +37,7 @@ public class BasicSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();
@ -68,7 +66,7 @@ public class BasicSequenceTest {
public void testSequencePerEntity(SessionFactoryScope scope) { public void testSequencePerEntity(SessionFactoryScope scope) {
final String overriddenEntityName = "SpecialEntity"; final String overriddenEntityName = "SpecialEntity";
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( overriddenEntityName ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(overriddenEntityName);
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();

View File

@ -17,7 +17,6 @@ import jakarta.persistence.Id;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Parameter;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.id.enhanced.HiLoOptimizer; import org.hibernate.id.enhanced.HiLoOptimizer;
@ -94,7 +93,7 @@ public class HiLoSequenceMismatchStrategyTest {
@Test @Test
public void testSequenceMismatchStrategyNotApplied(SessionFactoryScope scope) { public void testSequenceMismatchStrategyNotApplied(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( TestEntity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(TestEntity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();

View File

@ -31,7 +31,7 @@ public class HiLoSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();

View File

@ -30,7 +30,7 @@ public class PooledSequenceTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator(); final SequenceStyleGenerator generator = ( SequenceStyleGenerator ) persister.getIdentifierGenerator();

View File

@ -26,7 +26,7 @@ public class BasicTableTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) );
final TableGenerator generator = ( TableGenerator ) persister.getIdentifierGenerator(); final TableGenerator generator = ( TableGenerator ) persister.getIdentifierGenerator();

View File

@ -26,7 +26,7 @@ import static org.junit.Assert.assertThat;
public class HiLoTableTest { public class HiLoTableTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) );
final TableGenerator generator = (TableGenerator) persister.getIdentifierGenerator(); final TableGenerator generator = (TableGenerator) persister.getIdentifierGenerator();

View File

@ -26,7 +26,7 @@ import static org.junit.Assert.assertThat;
public class PooledTableTest { public class PooledTableTest {
@Test @Test
public void testNormalBoundary(SessionFactoryScope scope) { public void testNormalBoundary(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( Entity.class.getName() ); final EntityPersister persister = scope.getSessionFactory().getMetamodel().entityPersister(Entity.class.getName());
assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) ); assertThat( persister.getIdentifierGenerator(), instanceOf( TableGenerator.class ) );
final TableGenerator generator = (TableGenerator) persister.getIdentifierGenerator(); final TableGenerator generator = (TableGenerator) persister.getIdentifierGenerator();

View File

@ -56,8 +56,8 @@ public abstract class AbstractEntityWithManyToManyTest {
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
isPlanContractsBidirectional = false; isPlanContractsBidirectional = false;
} }
isPlanVersioned = sessionFactory.getEntityPersister( Plan.class.getName() ).isVersioned(); isPlanVersioned = sessionFactory.getMetamodel().entityPersister(Plan.class.getName()).isVersioned();
isContractVersioned = sessionFactory.getEntityPersister( Contract.class.getName() ).isVersioned(); isContractVersioned = sessionFactory.getMetamodel().entityPersister(Contract.class.getName()).isVersioned();
sessionFactory.getStatistics().clear(); sessionFactory.getStatistics().clear();
} }

View File

@ -45,14 +45,14 @@ public class JoinedSubclassWithExplicitDiscriminatorTest {
@Test @Test
public void metadataAssertions(SessionFactoryScope scope) { public void metadataAssertions(SessionFactoryScope scope) {
EntityPersister p = scope.getSessionFactory().getEntityPersister( Dog.class.getName() ); EntityPersister p = scope.getSessionFactory().getMetamodel().entityPersister(Dog.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( "string", dogPersister.getDiscriminatorType().getName() ); assertEquals( "string", dogPersister.getDiscriminatorType().getName() );
assertEquals( "type", dogPersister.getDiscriminatorColumnName() ); assertEquals( "type", dogPersister.getDiscriminatorColumnName() );
assertEquals( "dog", dogPersister.getDiscriminatorValue() ); assertEquals( "dog", dogPersister.getDiscriminatorValue() );
p = scope.getSessionFactory().getEntityPersister( Cat.class.getName() ); p = scope.getSessionFactory().getMetamodel().entityPersister(Cat.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( "string", catPersister.getDiscriminatorType().getName() ); assertEquals( "string", catPersister.getDiscriminatorType().getName() );

View File

@ -54,14 +54,14 @@ public class JoinedSubclassWithIgnoredExplicitDiscriminatorTest {
@Test @Test
public void metadataAssertions(SessionFactoryScope scope) { public void metadataAssertions(SessionFactoryScope scope) {
EntityPersister p = scope.getSessionFactory().getEntityPersister( Dog.class.getName() ); EntityPersister p = scope.getSessionFactory().getMetamodel().entityPersister(Dog.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( "integer", dogPersister.getDiscriminatorType().getName() ); assertEquals( "integer", dogPersister.getDiscriminatorType().getName() );
assertEquals( "clazz_", dogPersister.getDiscriminatorColumnName() ); assertEquals( "clazz_", dogPersister.getDiscriminatorColumnName() );
assertTrue( Integer.class.isInstance( dogPersister.getDiscriminatorValue() ) ); assertTrue( Integer.class.isInstance( dogPersister.getDiscriminatorValue() ) );
p = scope.getSessionFactory().getEntityPersister( Cat.class.getName() ); p = scope.getSessionFactory().getMetamodel().entityPersister(Cat.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( "integer", catPersister.getDiscriminatorType().getName() ); assertEquals( "integer", catPersister.getDiscriminatorType().getName() );

View File

@ -50,7 +50,7 @@ public class JoinedSubclassWithImplicitDiscriminatorTest {
@Test @Test
public void metadataAssertions(SessionFactoryScope scope) { public void metadataAssertions(SessionFactoryScope scope) {
EntityPersister p = scope.getSessionFactory().getEntityPersister( Dog.class.getName() ); EntityPersister p = scope.getSessionFactory().getMetamodel().entityPersister(Dog.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( assertEquals(
@ -63,7 +63,7 @@ public class JoinedSubclassWithImplicitDiscriminatorTest {
); );
assertEquals( "Dog", dogPersister.getDiscriminatorValue() ); assertEquals( "Dog", dogPersister.getDiscriminatorValue() );
p = scope.getSessionFactory().getEntityPersister( Cat.class.getName() ); p = scope.getSessionFactory().getMetamodel().entityPersister(Cat.class.getName());
assertNotNull( p ); assertNotNull( p );
final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p ); final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
assertEquals( assertEquals(

View File

@ -75,7 +75,7 @@ public class BasicJodaTimeConversionTest extends BaseNonConfigCoreFunctionalTest
@Test @Test
public void testSimpleConvertUsage() throws MalformedURLException { public void testSimpleConvertUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( TheEntity.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(TheEntity.class.getName());
final Type theDatePropertyType = ep.getPropertyType( "theDate" ); final Type theDatePropertyType = ep.getPropertyType( "theDate" );
final AttributeConverterTypeAdapter type = assertTyping( AttributeConverterTypeAdapter.class, theDatePropertyType ); final AttributeConverterTypeAdapter type = assertTyping( AttributeConverterTypeAdapter.class, theDatePropertyType );
assertTrue( JodaLocalDateConverter.class.isAssignableFrom( type.getAttributeConverter().getConverterJavaType().getJavaTypeClass() ) ); assertTrue( JodaLocalDateConverter.class.isAssignableFrom( type.getAttributeConverter().getConverterJavaType().getJavaTypeClass() ) );

View File

@ -115,7 +115,7 @@ public class DirtyCheckingTest extends BaseNonConfigCoreFunctionalTestCase {
@Test @Test
public void checkConverterMutabilityPlans() { public void checkConverterMutabilityPlans() {
final EntityPersister persister = sessionFactory().getEntityPersister( SomeEntity.class.getName() ); final EntityPersister persister = sessionFactory().getMetamodel().entityPersister(SomeEntity.class.getName());
final AttributeMapping numberMapping = persister.findAttributeMapping( "number" ); final AttributeMapping numberMapping = persister.findAttributeMapping( "number" );
final AttributeMapping nameMapping = persister.findAttributeMapping( "name" ); final AttributeMapping nameMapping = persister.findAttributeMapping( "name" );

View File

@ -80,7 +80,7 @@ public class ExplicitDateConvertersTest extends BaseNonConfigCoreFunctionalTestC
@Test @Test
public void testSimpleConvertUsage() throws MalformedURLException { public void testSimpleConvertUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( Entity1.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Entity1.class.getName());
final Type theDatePropertyType = ep.getPropertyType( "theDate" ); final Type theDatePropertyType = ep.getPropertyType( "theDate" );
final AttributeConverterTypeAdapter type = assertTyping( final AttributeConverterTypeAdapter type = assertTyping(
AttributeConverterTypeAdapter.class, AttributeConverterTypeAdapter.class,

View File

@ -88,7 +88,7 @@ public class ExplicitEnumConvertersTest extends BaseNonConfigCoreFunctionalTestC
@Test @Test
public void testSimpleConvertUsage() throws MalformedURLException { public void testSimpleConvertUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( Entity1.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Entity1.class.getName());
final Type theDatePropertyType = ep.getPropertyType( "mediaType" ); final Type theDatePropertyType = ep.getPropertyType( "mediaType" );
final AttributeConverterTypeAdapter type = assertTyping( final AttributeConverterTypeAdapter type = assertTyping(
AttributeConverterTypeAdapter.class, AttributeConverterTypeAdapter.class,

View File

@ -39,7 +39,7 @@ public class SimpleConvertAnnotationTest extends BaseNonConfigCoreFunctionalTest
@Test @Test
public void testSimpleConvertUsage() throws MalformedURLException { public void testSimpleConvertUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( Entity1.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Entity1.class.getName());
final Type websitePropertyType = ep.getPropertyType( "website" ); final Type websitePropertyType = ep.getPropertyType( "website" );
final AttributeConverterTypeAdapter type = assertTyping( final AttributeConverterTypeAdapter type = assertTyping(
AttributeConverterTypeAdapter.class, AttributeConverterTypeAdapter.class,

View File

@ -40,7 +40,7 @@ public class SimpleConvertsAnnotationTest extends BaseNonConfigCoreFunctionalTes
@Test @Test
public void testSimpleConvertsUsage() throws MalformedURLException { public void testSimpleConvertsUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( Entity1.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Entity1.class.getName());
final Type websitePropertyType = ep.getPropertyType( "website" ); final Type websitePropertyType = ep.getPropertyType( "website" );
final AttributeConverterTypeAdapter type = assertTyping( final AttributeConverterTypeAdapter type = assertTyping(
AttributeConverterTypeAdapter.class, AttributeConverterTypeAdapter.class,

View File

@ -47,7 +47,7 @@ public class SimpleEmbeddableOverriddenConverterTest extends BaseNonConfigCoreFu
*/ */
@Test @Test
public void testSimpleConvertOverrides() { public void testSimpleConvertOverrides() {
final EntityPersister ep = sessionFactory().getEntityPersister( Person.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Person.class.getName());
final JdbcTypeRegistry jdbcTypeRegistry = sessionFactory().getTypeConfiguration() final JdbcTypeRegistry jdbcTypeRegistry = sessionFactory().getTypeConfiguration()
.getJdbcTypeRegistry(); .getJdbcTypeRegistry();
CompositeType homeAddressType = assertTyping( CompositeType.class, ep.getPropertyType( "homeAddress" ) ); CompositeType homeAddressType = assertTyping( CompositeType.class, ep.getPropertyType( "homeAddress" ) );

View File

@ -44,7 +44,7 @@ public class SimpleOverriddenConverterTest extends BaseNonConfigCoreFunctionalTe
*/ */
@Test @Test
public void testSimpleConvertOverrides() { public void testSimpleConvertOverrides() {
final EntityPersister ep = sessionFactory().getEntityPersister( Sub.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Sub.class.getName());
final JdbcTypeRegistry jdbcTypeRegistry = sessionFactory().getTypeConfiguration() final JdbcTypeRegistry jdbcTypeRegistry = sessionFactory().getTypeConfiguration()
.getJdbcTypeRegistry(); .getJdbcTypeRegistry();

View File

@ -97,7 +97,7 @@ public class XmlWithExplicitConvertAnnotationsTest extends BaseNonConfigCoreFunc
@Test @Test
public void testSimpleConvertUsage() throws MalformedURLException { public void testSimpleConvertUsage() throws MalformedURLException {
final EntityPersister ep = sessionFactory().getEntityPersister( Entity1.class.getName() ); final EntityPersister ep = sessionFactory().getMetamodel().entityPersister(Entity1.class.getName());
final Type theDatePropertyType = ep.getPropertyType( "theDate" ); final Type theDatePropertyType = ep.getPropertyType( "theDate" );
final AttributeConverterTypeAdapter type = assertTyping( final AttributeConverterTypeAdapter type = assertTyping(
AttributeConverterTypeAdapter.class, AttributeConverterTypeAdapter.class,

View File

@ -162,7 +162,7 @@ public class CacheLazyLoadNoTransTest {
Object value = scope.fromSession( Object value = scope.fromSession(
session -> { session -> {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory(); final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
CollectionPersister persister = sessionFactory.getCollectionPersister( entityClass.getName() + "." + attr ); CollectionPersister persister = sessionFactory.getMetamodel().collectionPersister(entityClass.getName() + "." + attr);
CollectionDataAccess cache = persister.getCacheAccessStrategy(); CollectionDataAccess cache = persister.getCacheAccessStrategy();
Object key = cache.generateCacheKey( id, persister, sessionFactory, session.getTenantIdentifier() ); Object key = cache.generateCacheKey( id, persister, sessionFactory, session.getTenantIdentifier() );
Object cachedValue = cache.get( session, key ); Object cachedValue = cache.get( session, key );

View File

@ -48,8 +48,8 @@ public class CustomSqlSchemaResolvingIdentityTest {
public void testSchemaNotReplacedInCustomSQL(SessionFactoryScope scope) throws Exception { public void testSchemaNotReplacedInCustomSQL(SessionFactoryScope scope) throws Exception {
String className = CustomEntity.class.getName(); String className = CustomEntity.class.getName();
final AbstractEntityPersister persister = (AbstractEntityPersister) scope.getSessionFactory().getEntityPersister( className ); final AbstractEntityPersister persister = (AbstractEntityPersister) scope.getSessionFactory().getMetamodel().entityPersister(className);
String insertQuery = persister.getSQLInsertStrings()[0]; String insertQuery = persister.getSQLInsertStrings()[0];
String updateQuery = persister.getSQLUpdateStrings()[0]; String updateQuery = persister.getSQLUpdateStrings()[0];
String deleteQuery = persister.getSQLDeleteStrings()[0]; String deleteQuery = persister.getSQLDeleteStrings()[0];

View File

@ -43,7 +43,7 @@ public class CustomSqlSchemaResolvingTest {
String className = CustomEntity.class.getName(); String className = CustomEntity.class.getName();
final AbstractEntityPersister persister = (AbstractEntityPersister) scope.getSessionFactory().getEntityPersister( className ); final AbstractEntityPersister persister = (AbstractEntityPersister) scope.getSessionFactory().getMetamodel().entityPersister(className);
String insertQuery = persister.getSQLInsertStrings()[0]; String insertQuery = persister.getSQLInsertStrings()[0];
String updateQuery = persister.getSQLUpdateStrings()[0]; String updateQuery = persister.getSQLUpdateStrings()[0];
String deleteQuery = persister.getSQLDeleteStrings()[0]; String deleteQuery = persister.getSQLDeleteStrings()[0];

View File

@ -483,9 +483,9 @@ public class ProxyTest extends BaseCoreFunctionalTestCase {
s.delete( container ); s.delete( container );
// force a snapshot retrieval of the proxied container // force a snapshot retrieval of the proxied container
SessionImpl sImpl = ( SessionImpl ) s; SessionImpl sImpl = ( SessionImpl ) s;
sImpl.getPersistenceContext().getDatabaseSnapshot( sImpl.getPersistenceContext().getDatabaseSnapshot(
lastContainerId, lastContainerId,
sImpl.getFactory().getEntityPersister( Container.class.getName() ) sImpl.getFactory().getMetamodel().entityPersister(Container.class.getName())
); );
assertFalse( Hibernate.isInitialized( proxy ) ); assertFalse( Hibernate.isInitialized( proxy ) );
t.commit(); t.commit();

View File

@ -39,8 +39,8 @@ public class SybaseTimestampComparisonAnnotationsTest extends BaseCoreFunctional
@Test @Test
@TestForIssue( jiraKey = "HHH-10413" ) @TestForIssue( jiraKey = "HHH-10413" )
public void testComparableTimestamps() { public void testComparableTimestamps() {
final BasicType<?> versionType = final BasicType<?> versionType =
sessionFactory().getEntityPersister( Thing.class.getName() ).getVersionType(); sessionFactory().getMetamodel().entityPersister(Thing.class.getName()).getVersionType();
assertTrue( versionType.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType ); assertTrue( versionType.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType );
assertTrue( versionType.getJdbcType() instanceof VarbinaryJdbcType ); assertTrue( versionType.getJdbcType() instanceof VarbinaryJdbcType );

View File

@ -234,8 +234,8 @@ public class SybaseTimestampVersioningTest extends BaseCoreFunctionalTestCase {
@Test @Test
@TestForIssue( jiraKey = "HHH-10413" ) @TestForIssue( jiraKey = "HHH-10413" )
public void testComparableTimestamps() { public void testComparableTimestamps() {
final BasicType<?> versionType = final BasicType<?> versionType =
sessionFactory().getEntityPersister( User.class.getName() ).getVersionType(); sessionFactory().getMetamodel().entityPersister(User.class.getName()).getVersionType();
assertTrue( versionType.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType ); assertTrue( versionType.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType );
assertTrue( versionType.getJdbcType() instanceof VarbinaryJdbcType ); assertTrue( versionType.getJdbcType() instanceof VarbinaryJdbcType );

View File

@ -66,7 +66,7 @@ public class CMTTest extends BaseNonConfigCoreFunctionalTestCase {
assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheHitCount() ); assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheHitCount() );
assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCachePutCount() ); assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCachePutCount() );
assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheMissCount() ); assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheMissCount() );
assertNotNull( sessionFactory().getEntityPersister( "Item" ).getCacheAccessStrategy() ); assertNotNull( sessionFactory().getMetamodel().entityPersister("Item").getCacheAccessStrategy() );
assertEquals( 0, sessionFactory().getStatistics().getEntityLoadCount() ); assertEquals( 0, sessionFactory().getStatistics().getEntityLoadCount() );
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin(); TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();

View File

@ -40,7 +40,7 @@ public class MonotonicRevisionNumberTest extends BaseEnversFunctionalTestCase {
@Test @Test
public void testOracleSequenceOrder() { public void testOracleSequenceOrder() {
EntityPersister persister = sessionFactory().getEntityPersister( SequenceIdRevisionEntity.class.getName() ); EntityPersister persister = sessionFactory().getMetamodel().entityPersister(SequenceIdRevisionEntity.class.getName());
IdentifierGenerator generator = persister.getIdentifierGenerator(); IdentifierGenerator generator = persister.getIdentifierGenerator();
Assert.assertTrue( OrderedSequenceGenerator.class.isInstance( generator ) ); Assert.assertTrue( OrderedSequenceGenerator.class.isInstance( generator ) );