add MappingMetamodel.isEntityClass() and clean up raw types
This commit is contained in:
parent
0bf2365955
commit
0b2a357670
|
@ -31,6 +31,7 @@ import org.hibernate.LockMode;
|
|||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.SessionException;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.UnknownEntityTypeException;
|
||||
import org.hibernate.cache.spi.CacheTransactionSynchronization;
|
||||
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
|
@ -729,7 +730,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
if ( Tuple.class.equals(resultClass) ) {
|
||||
query.setTupleTransformer( new NativeQueryTupleTransformer() );
|
||||
}
|
||||
else if ( getFactory().getMetamodel().findEntityDescriptor(resultClass)!=null ) {
|
||||
else if ( getFactory().getMetamodel().isEntityClass(resultClass) ) {
|
||||
query.addEntity( "alias1", resultClass.getName(), LockMode.READ );
|
||||
}
|
||||
return query;
|
||||
|
@ -738,12 +739,12 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
@Override @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) {
|
||||
NativeQueryImplementor query = createNativeQuery( sqlString );
|
||||
if ( Tuple.class.equals(resultClass) ) {
|
||||
query.setTupleTransformer( new NativeQueryTupleTransformer() );
|
||||
}
|
||||
else if ( getFactory().getMetamodel().findEntityDescriptor(resultClass)!=null ) {
|
||||
if ( getFactory().getMetamodel().isEntityClass(resultClass) ) {
|
||||
query.addEntity( tableAlias, resultClass.getName(), LockMode.READ );
|
||||
}
|
||||
else {
|
||||
throw new UnknownEntityTypeException( "unable to locate persister: " + resultClass.getName() );
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.hibernate.persister.collection.CollectionPersister;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.SqmExpressable;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -90,7 +89,7 @@ public interface MappingMetamodel {
|
|||
*
|
||||
* @see #findEntityDescriptor
|
||||
*/
|
||||
EntityPersister getEntityDescriptor(Class entityJavaType);
|
||||
EntityPersister getEntityDescriptor(Class<?> entityJavaType);
|
||||
|
||||
/**
|
||||
* Find an entity mapping descriptor based on its Hibernate entity-name.
|
||||
|
@ -104,7 +103,9 @@ public interface MappingMetamodel {
|
|||
*
|
||||
* @apiNote Returns {@code null} rather than throwing exception
|
||||
*/
|
||||
EntityPersister findEntityDescriptor(Class entityJavaType);
|
||||
EntityPersister findEntityDescriptor(Class<?> entityJavaType);
|
||||
|
||||
boolean isEntityClass(Class<?> entityJavaType);
|
||||
|
||||
/**
|
||||
* Locate an entity mapping descriptor by Class. The passed Class might
|
||||
|
@ -114,7 +115,7 @@ public interface MappingMetamodel {
|
|||
*
|
||||
* @throws org.hibernate.UnknownEntityTypeException If a matching EntityPersister cannot be located
|
||||
*/
|
||||
EntityPersister locateEntityDescriptor(Class byClass);
|
||||
EntityPersister locateEntityDescriptor(Class<?> byClass);
|
||||
|
||||
/**
|
||||
* @see #locateEntityDescriptor
|
||||
|
@ -122,7 +123,7 @@ public interface MappingMetamodel {
|
|||
* @deprecated (since 6.0) use {@link #locateEntityDescriptor(Class)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
default EntityPersister locateEntityPersister(Class byClass) {
|
||||
default EntityPersister locateEntityPersister(Class<?> byClass) {
|
||||
return locateEntityDescriptor( byClass );
|
||||
}
|
||||
|
||||
|
|
|
@ -401,17 +401,22 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister findEntityDescriptor(Class entityJavaType) {
|
||||
public EntityPersister findEntityDescriptor(Class<?> entityJavaType) {
|
||||
return findEntityDescriptor( entityJavaType.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntityClass(Class<?> entityJavaType) {
|
||||
return entityPersisterMap.containsKey( entityJavaType.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryImplementor getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister getEntityDescriptor(Class entityJavaType) {
|
||||
public EntityPersister getEntityDescriptor(Class<?> entityJavaType) {
|
||||
EntityPersister entityPersister = entityPersisterMap.get( entityJavaType.getName() );
|
||||
if ( entityPersister == null ) {
|
||||
String mappedEntityName = entityProxyInterfaceMap.get( entityJavaType );
|
||||
|
@ -428,7 +433,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister locateEntityDescriptor(Class byClass) {
|
||||
public EntityPersister locateEntityDescriptor(Class<?> byClass) {
|
||||
EntityPersister entityPersister = entityPersisterMap.get( byClass.getName() );
|
||||
if ( entityPersister == null ) {
|
||||
String mappedEntityName = entityProxyInterfaceMap.get( byClass );
|
||||
|
@ -562,7 +567,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister entityPersister(Class entityClass) {
|
||||
public EntityPersister entityPersister(Class<?> entityClass) {
|
||||
return entityPersister( entityClass.getName() );
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
*
|
||||
* @throws MappingException Indicates persister for that class could not be found.
|
||||
*/
|
||||
EntityPersister entityPersister(Class entityClass);
|
||||
EntityPersister entityPersister(Class<?> entityClass);
|
||||
|
||||
/**
|
||||
* Locate the persister for an entity by the entity-name
|
||||
|
|
Loading…
Reference in New Issue