Have SessionFactory#getMetamodel() return a JpaMetamodel
It just makes sense, since JpaMetamodel is Hibernate ORM's extension of jakarta.persistence.metamodel.Metamodel, and SessionFactory#getMetamodel() is Hibernate ORM's extension of EntityManager#getMetamodel().
This commit is contained in:
parent
a16305e01f
commit
e93d33be16
|
@ -8,7 +8,6 @@ package org.hibernate;
|
|||
|
||||
import jakarta.persistence.metamodel.EntityType;
|
||||
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +18,7 @@ import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
|||
* @see JpaMetamodel
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Metamodel extends jakarta.persistence.metamodel.Metamodel {
|
||||
public interface Metamodel extends JpaMetamodel {
|
||||
/**
|
||||
* Access to the SessionFactory that this Metamodel instance is bound to.
|
||||
*
|
||||
|
@ -35,15 +34,6 @@ public interface Metamodel extends jakarta.persistence.metamodel.Metamodel {
|
|||
return entity( entityName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to an entity supporting Hibernate's entity-name feature
|
||||
*
|
||||
* @param entityName The entity-name
|
||||
*
|
||||
* @return The entity descriptor
|
||||
*/
|
||||
<X> EntityDomainType<X> entity(String entityName);
|
||||
|
||||
String getImportedClassName(String className);
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.hibernate.graph.spi.RootGraphImplementor;
|
|||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.HEMLogging;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.jpa.spi.JpaCompliance;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
|
@ -471,6 +472,56 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
|||
return jpaMetamodel.entity( entityName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> EntityDomainType<X> getHqlEntityReference(String entityName) {
|
||||
return jpaMetamodel.getHqlEntityReference( entityName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> EntityDomainType<X> resolveHqlEntityReference(String entityName) {
|
||||
return jpaMetamodel.resolveHqlEntityReference( entityName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitManagedTypes(Consumer<ManagedDomainType<?>> action) {
|
||||
jpaMetamodel.visitManagedTypes( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
|
||||
return jpaMetamodel.findManagedType( cls );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEntityTypes(Consumer<EntityDomainType<?>> action) {
|
||||
jpaMetamodel.visitEntityTypes( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
|
||||
return jpaMetamodel.findEntityType( cls );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitRootEntityTypes(Consumer<EntityDomainType<?>> action) {
|
||||
jpaMetamodel.visitRootEntityTypes( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEmbeddables(Consumer<EmbeddableDomainType<?>> action) {
|
||||
jpaMetamodel.visitEmbeddables( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String qualifyImportableName(String queryName) {
|
||||
return jpaMetamodel.qualifyImportableName( queryName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<Class<?>, Enum<?>>> getAllowedEnumLiteralTexts() {
|
||||
return jpaMetamodel.getAllowedEnumLiteralTexts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportedClassName(String className) {
|
||||
throw new UnsupportedOperationException( );
|
||||
|
@ -616,6 +667,11 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
|||
return jpaMetamodel.findEntityGraphsByJavaType( entityClass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaCompliance getJpaCompliance() {
|
||||
return jpaMetamodel.getJpaCompliance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootGraph<?> findNamedGraph(String name) {
|
||||
return findEntityGraphByName( name );
|
||||
|
|
|
@ -18,9 +18,7 @@ import org.hibernate.Metamodel;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.graph.spi.RootGraphImplementor;
|
||||
import org.hibernate.metamodel.MappingMetamodel;
|
||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
|
@ -110,18 +108,12 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
*/
|
||||
String[] getAllCollectionRoles();
|
||||
|
||||
<T> void addNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #addNamedEntityGraph(String, RootGraphImplementor)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
<T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph);
|
||||
|
||||
<T> RootGraphImplementor<T> findEntityGraphByName(String name);
|
||||
|
||||
<T> List<RootGraphImplementor<? super T>> findEntityGraphsByJavaType(Class<T> entityClass);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #findEntityGraphsByJavaType(Class)} instead.
|
||||
*/
|
||||
|
@ -136,16 +128,6 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Co-variant returns
|
||||
|
||||
|
||||
@Override
|
||||
<X> EntityDomainType<X> entity(Class<X> cls);
|
||||
|
||||
@Override
|
||||
<X> ManagedDomainType<X> managedType(Class<X> cls);
|
||||
|
||||
@Override
|
||||
<X> EmbeddableDomainType<X> embeddable(Class<X> cls);
|
||||
|
||||
@Override
|
||||
default EntityDomainType getEntityTypeByName(String entityName) {
|
||||
return entity( entityName );
|
||||
|
|
Loading…
Reference in New Issue