get rid of some more usages of getMetamodel()
This commit is contained in:
parent
a3ef7b906d
commit
e82a5492c3
|
@ -54,8 +54,9 @@ import org.hibernate.type.descriptor.WrapperOptions;
|
|||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Base delegating implementation of the SessionFactory and SessionFactoryImplementor
|
||||
* contracts for intended for easier implementation of SessionFactory.
|
||||
* Base delegating implementation of the {@link SessionFactory} and
|
||||
* {@link SessionFactoryImplementor} contracts for intended for easier
|
||||
* implementation of {@link SessionFactory}.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -195,6 +196,16 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
|||
return delegate.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcServices getJdbcServices() {
|
||||
return delegate.getJdbcServices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlStringGenerationContext getSqlStringGenerationContext() {
|
||||
return delegate.getSqlStringGenerationContext();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public EntityPersister getEntityPersister(String entityName) throws MappingException {
|
||||
return delegate.getRuntimeMetamodels()
|
||||
|
@ -223,16 +234,6 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
|||
return delegate.getMetamodel().collectionPersisters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcServices getJdbcServices() {
|
||||
return delegate.getJdbcServices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlStringGenerationContext getSqlStringGenerationContext() {
|
||||
return delegate.getSqlStringGenerationContext();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String[] getImplementors(String className) throws MappingException {
|
||||
// for the time being, leave this calling `MetamodelImplementor` - nothing uses
|
||||
|
@ -375,7 +376,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
|||
return delegate.getCriteriaBuilder();
|
||||
}
|
||||
|
||||
@Override @SuppressWarnings("deprecation")
|
||||
@Override @Deprecated
|
||||
public MetamodelImplementor getMetamodel() {
|
||||
return delegate.getMetamodel();
|
||||
}
|
||||
|
|
|
@ -169,7 +169,10 @@ public interface SessionFactoryImplementor
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// map these to Metamodel
|
||||
|
||||
@Override @SuppressWarnings("deprecation")
|
||||
/**
|
||||
* @deprecated no longer for internal use, use {@link #getMappingMetamodel()} or {@link #getJpaMetamodel()}
|
||||
*/
|
||||
@Override @Deprecated
|
||||
MetamodelImplementor getMetamodel();
|
||||
|
||||
RootGraphImplementor<?> findEntityGraphByName(String name);
|
||||
|
|
|
@ -795,7 +795,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
if ( Tuple.class.equals(resultClass) ) {
|
||||
query.setTupleTransformer( new NativeQueryTupleTransformer() );
|
||||
}
|
||||
else if ( getFactory().getMetamodel().isEntityClass(resultClass) ) {
|
||||
else if ( getFactory().getMappingMetamodel().isEntityClass(resultClass) ) {
|
||||
query.addEntity( "alias1", resultClass.getName(), LockMode.READ );
|
||||
}
|
||||
return query;
|
||||
|
@ -805,7 +805,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias) {
|
||||
@SuppressWarnings("unchecked")
|
||||
NativeQueryImplementor<T> query = createNativeQuery( sqlString );
|
||||
if ( getFactory().getMetamodel().isEntityClass(resultClass) ) {
|
||||
if ( getFactory().getMappingMetamodel().isEntityClass(resultClass) ) {
|
||||
query.addEntity( tableAlias, resultClass.getName(), LockMode.READ );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -95,7 +95,6 @@ import org.hibernate.metamodel.internal.RuntimeMetamodelsImpl;
|
|||
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
|
||||
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
|
||||
import org.hibernate.query.BindableType;
|
||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
|
||||
import org.hibernate.metamodel.spi.MetamodelImplementor;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
@ -515,7 +514,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
|
||||
@Override
|
||||
public SessionBuilderImplementor withOptions() {
|
||||
return new SessionBuilderImpl( this );
|
||||
return new SessionBuilderImpl<>( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -602,7 +601,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
|
||||
@Override
|
||||
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
|
||||
return (List) getMetamodel().findEntityGraphsByJavaType( entityClass );
|
||||
return (List) getJpaMetamodel().findEntityGraphsByJavaType( entityClass );
|
||||
}
|
||||
|
||||
// todo : (5.2) review synchronizationType, persistenceContextType, transactionType usage
|
||||
|
@ -617,12 +616,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
assert status != Status.CLOSED;
|
||||
|
||||
SessionBuilderImplementor builder = withOptions();
|
||||
if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) {
|
||||
builder.autoJoinTransactions( true );
|
||||
}
|
||||
else {
|
||||
builder.autoJoinTransactions( false );
|
||||
}
|
||||
builder.autoJoinTransactions( synchronizationType == SynchronizationType.SYNCHRONIZED );
|
||||
|
||||
final Session session = builder.openSession();
|
||||
if ( map != null ) {
|
||||
|
@ -688,7 +682,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
|
||||
@Override
|
||||
public RootGraphImplementor<?> findEntityGraphByName(String name) {
|
||||
return getMetamodel().findEntityGraphByName( name );
|
||||
return getJpaMetamodel().findEntityGraphByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -952,7 +946,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
|
||||
@Override
|
||||
public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) {
|
||||
getMetamodel().addNamedEntityGraph( graphName, (RootGraphImplementor<T>) entityGraph );
|
||||
getMappingMetamodel().addNamedEntityGraph( graphName, (RootGraphImplementor<T>) entityGraph );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.persistence.metamodel.Metamodel;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.ConnectionAcquisitionMode;
|
||||
import org.hibernate.Filter;
|
||||
|
@ -114,7 +115,6 @@ import org.hibernate.loader.access.IdentifierLoadAccessImpl;
|
|||
import org.hibernate.loader.access.LoadAccessContext;
|
||||
import org.hibernate.loader.access.NaturalIdLoadAccessImpl;
|
||||
import org.hibernate.loader.access.SimpleNaturalIdLoadAccessImpl;
|
||||
import org.hibernate.metamodel.spi.MetamodelImplementor;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.pretty.MessageHelper;
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
|
@ -334,7 +334,7 @@ public class SessionImpl
|
|||
|
||||
@Override
|
||||
public SharedSessionBuilder sessionWithOptions() {
|
||||
return new SharedSessionBuilderImpl( this );
|
||||
return new SharedSessionBuilderImpl<>( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2703,15 +2703,19 @@ public class SessionImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public MetamodelImplementor getMetamodel() {
|
||||
public Metamodel getMetamodel() {
|
||||
checkOpen();
|
||||
return getFactory().getMetamodel();
|
||||
return getFactory().getJpaMetamodel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> RootGraphImplementor<T> createEntityGraph(Class<T> rootType) {
|
||||
checkOpen();
|
||||
return new RootGraphImpl<>( null, getMetamodel().entity( rootType ), getEntityManagerFactory().getJpaMetamodel() );
|
||||
return new RootGraphImpl<>(
|
||||
null,
|
||||
getFactory().getJpaMetamodel().entity( rootType ),
|
||||
getEntityManagerFactory().getJpaMetamodel()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -456,7 +456,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
expressibleType = (DomainType<R>) typeConfiguration.resolveTupleType( sqmExpressions );
|
||||
}
|
||||
else {
|
||||
expressibleType = typeConfiguration.getSessionFactory().getMetamodel().embeddable( tupleType );
|
||||
expressibleType = typeConfiguration.getSessionFactory().getJpaMetamodel().embeddable( tupleType );
|
||||
}
|
||||
return tuple( expressibleType, sqmExpressions );
|
||||
}
|
||||
|
@ -962,15 +962,9 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
|||
public <T> SqmExpression<T> nullLiteral(Class<T> resultClass) {
|
||||
final TypeConfiguration typeConfiguration = getTypeConfiguration();
|
||||
final BasicType<T> basicTypeForJavaType = typeConfiguration.getBasicTypeForJavaType( resultClass );
|
||||
final SqmExpressible<T> sqmExpressible;
|
||||
if ( basicTypeForJavaType == null ) {
|
||||
sqmExpressible = typeConfiguration.getSessionFactory()
|
||||
.getMetamodel()
|
||||
.managedType( resultClass );
|
||||
}
|
||||
else {
|
||||
sqmExpressible = basicTypeForJavaType;
|
||||
}
|
||||
final SqmExpressible<T> sqmExpressible = basicTypeForJavaType == null
|
||||
? typeConfiguration.getSessionFactory().getJpaMetamodel().managedType( resultClass )
|
||||
: basicTypeForJavaType;
|
||||
return new SqmLiteralNull<>(sqmExpressible, this );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.orm.test.jpa.criteria;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -20,6 +19,7 @@ import jakarta.persistence.criteria.Predicate;
|
|||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.SetJoin;
|
||||
import jakarta.persistence.metamodel.EntityType;
|
||||
import jakarta.persistence.metamodel.Metamodel;
|
||||
import org.hibernate.dialect.CockroachDialect;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Address;
|
||||
|
@ -35,7 +35,6 @@ import org.hibernate.orm.test.jpa.metamodel.Phone;
|
|||
import org.hibernate.orm.test.jpa.metamodel.Product;
|
||||
import org.hibernate.orm.test.jpa.metamodel.ShelfLife;
|
||||
import org.hibernate.orm.test.jpa.metamodel.Spouse;
|
||||
import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
|
@ -77,7 +76,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
em.getTransaction().begin();
|
||||
|
||||
CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
MappingMetamodelImpl mm = (MappingMetamodelImpl) em.getMetamodel();
|
||||
Metamodel mm = em.getMetamodel();
|
||||
|
||||
CriteriaQuery<Integer> cquery = cb.createQuery( Integer.class );
|
||||
Root<Product> product = cquery.from( Product.class );
|
||||
|
@ -120,7 +119,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
Phone phone3 = new Phone( "3", "555", "0003", address );
|
||||
Phone phone4 = new Phone( "4", "555", "0004" );
|
||||
|
||||
List<Phone> phones = new ArrayList<Phone>( 3 );
|
||||
List<Phone> phones = new ArrayList<>( 3 );
|
||||
phones.add( phone1 );
|
||||
phones.add( phone2 );
|
||||
phones.add( phone3 );
|
||||
|
@ -135,7 +134,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
em.getTransaction().begin();
|
||||
|
||||
CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
MappingMetamodelImpl mm = (MappingMetamodelImpl) em.getMetamodel();
|
||||
Metamodel mm = em.getMetamodel();
|
||||
EntityType<Phone> Phone_ = mm.entity( Phone.class );
|
||||
|
||||
CriteriaQuery<Phone> cquery = cb.createQuery( Phone.class );
|
||||
|
@ -157,7 +156,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
MappingMetamodelImpl mm = (MappingMetamodelImpl) em.getMetamodel();
|
||||
Metamodel mm = em.getMetamodel();
|
||||
EntityType<Product> Product_ = mm.entity( Product.class );
|
||||
|
||||
// toFloat
|
||||
|
@ -189,7 +188,6 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
MappingMetamodelImpl mm = (MappingMetamodelImpl) em.getMetamodel();
|
||||
|
||||
CriteriaQuery<Customer> cquery = cb.createQuery( Customer.class );
|
||||
Root<Customer> customer = cquery.from( Customer.class );
|
||||
|
@ -236,7 +234,6 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaBuilder cb = em.getCriteriaBuilder();
|
||||
MappingMetamodelImpl mm = (MappingMetamodelImpl) em.getMetamodel();
|
||||
|
||||
CriteriaQuery<java.sql.Date> dateQuery = cb.createQuery( java.sql.Date.class );
|
||||
dateQuery.from( Customer.class );
|
||||
|
@ -328,7 +325,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
|||
entityManager.persist( store );
|
||||
|
||||
final Book book = new Book();
|
||||
book.setStores( new HashSet<>( Arrays.asList( store ) ) );
|
||||
book.setStores( new HashSet<>( List.of(store) ) );
|
||||
entityManager.persist( book );
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in New Issue