make some methods protected for the benefit of HR
misc minor changes
This commit is contained in:
parent
577b6b1403
commit
8f5d5fd14c
|
@ -726,7 +726,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return query;
|
||||
}
|
||||
|
||||
private <R> HqlInterpretation interpretHql(String hql, Class<R> resultType) {
|
||||
protected <R> HqlInterpretation interpretHql(String hql, Class<R> resultType) {
|
||||
final QueryEngine queryEngine = getFactory().getQueryEngine();
|
||||
return queryEngine.getInterpretationCache()
|
||||
.resolveHqlInterpretation(
|
||||
|
@ -736,13 +736,13 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
);
|
||||
}
|
||||
|
||||
private static void checkSelectionQuery(String hql, HqlInterpretation hqlInterpretation) {
|
||||
protected static void checkSelectionQuery(String hql, HqlInterpretation hqlInterpretation) {
|
||||
if ( !( hqlInterpretation.getSqmStatement() instanceof SqmSelectStatement ) ) {
|
||||
throw new IllegalSelectQueryException( "Expecting a selection query, but found `" + hql + "`", hql);
|
||||
}
|
||||
}
|
||||
|
||||
private static <R> void checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<?> query) {
|
||||
protected static <R> void checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<?> query) {
|
||||
final Class<?> resultType = query.getResultType();
|
||||
if ( !expectedResultType.isAssignableFrom( resultType ) ) {
|
||||
throw new QueryTypeMismatchException(
|
||||
|
@ -841,6 +841,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
// the clashing signatures declared by the supertypes
|
||||
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass) {
|
||||
final NativeQueryImpl query = createNativeQuery( sqlString );
|
||||
addResultType( resultClass, query );
|
||||
return query;
|
||||
}
|
||||
|
||||
protected <T> void addResultType(Class<T> resultClass, NativeQueryImplementor<T> query) {
|
||||
if ( Tuple.class.equals( resultClass ) ) {
|
||||
query.setTupleTransformer( new NativeQueryTupleTransformer() );
|
||||
}
|
||||
|
@ -850,7 +855,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
else if ( resultClass != Object.class && resultClass != Object[].class ) {
|
||||
query.addResultTypeClass( resultClass );
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1020,7 +1024,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
}
|
||||
}
|
||||
|
||||
private <T> NativeQueryImplementor<T> createNativeQueryImplementor(Class<T> resultType, NamedNativeQueryMemento memento) {
|
||||
protected <T> NativeQueryImplementor<T> createNativeQueryImplementor(Class<T> resultType, NamedNativeQueryMemento memento) {
|
||||
final NativeQueryImplementor<T> query = resultType == null
|
||||
? memento.toQuery(this )
|
||||
: memento.toQuery(this, resultType );
|
||||
|
@ -1031,7 +1035,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return query;
|
||||
}
|
||||
|
||||
private <T> SqmQueryImplementor<T> createSqmQueryImplementor(Class<T> resultType, NamedSqmQueryMemento memento) {
|
||||
protected <T> SqmQueryImplementor<T> createSqmQueryImplementor(Class<T> resultType, NamedSqmQueryMemento memento) {
|
||||
final SqmQueryImplementor<T> query = memento.toQuery( this, resultType );
|
||||
if ( isEmpty( query.getComment() ) ) {
|
||||
query.setComment( "dynamic query" );
|
||||
|
@ -1078,7 +1082,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return query;
|
||||
}
|
||||
|
||||
private static void checkMutationQuery(String hqlString, SqmStatement<?> sqmStatement) {
|
||||
protected static void checkMutationQuery(String hqlString, SqmStatement<?> sqmStatement) {
|
||||
if ( !( sqmStatement instanceof SqmDmlStatement ) ) {
|
||||
throw new IllegalMutationQueryException( "Expecting a mutation query, but found `" + hqlString + "`" );
|
||||
}
|
||||
|
@ -1102,7 +1106,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
);
|
||||
}
|
||||
|
||||
private NativeQueryImplementor<?> createNativeQueryImplementor(String queryName, NamedNativeQueryMemento memento) {
|
||||
protected NativeQueryImplementor<?> createNativeQueryImplementor(String queryName, NamedNativeQueryMemento memento) {
|
||||
final NativeQueryImplementor<?> query = memento.toQuery( this );
|
||||
final Boolean isUnequivocallySelect = query.isSelectQuery();
|
||||
if ( isUnequivocallySelect == TRUE ) {
|
||||
|
@ -1118,7 +1122,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return query;
|
||||
}
|
||||
|
||||
private SqmQueryImplementor<?> createSqmQueryImplementor(String queryName, NamedSqmQueryMemento memento) {
|
||||
protected SqmQueryImplementor<?> createSqmQueryImplementor(String queryName, NamedSqmQueryMemento memento) {
|
||||
final SqmQueryImplementor<?> query = memento.toQuery( this );
|
||||
final SqmStatement<?> sqmStatement = query.getSqmStatement();
|
||||
if ( !( sqmStatement instanceof SqmDmlStatement ) ) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.engine.internal.StatefulPersistenceContext;
|
|||
import org.hibernate.engine.spi.EntityKey;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
|
@ -185,9 +186,8 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
public Object get(String entityName, Object id, LockMode lockMode) {
|
||||
checkOpen();
|
||||
|
||||
final EntityPersister entityDescriptor = getEntityPersister( entityName );
|
||||
final Object result = entityDescriptor.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
|
||||
final Object result = getEntityPersister( entityName )
|
||||
.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
if ( temporaryPersistenceContext.isLoadFinished() ) {
|
||||
temporaryPersistenceContext.clear();
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
|
||||
// first, try to load it from the temp PC associated to this SS
|
||||
final PersistenceContext persistenceContext = getPersistenceContext();
|
||||
Object loaded = persistenceContext.getEntity( entityKey );
|
||||
final Object loaded = persistenceContext.getEntity( entityKey );
|
||||
if ( loaded != null ) {
|
||||
// we found it in the temp PC. Should indicate we are in the midst of processing a result set
|
||||
// containing eager fetches via join fetch
|
||||
|
@ -305,8 +305,8 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
// first, check to see if we can use "bytecode proxies"
|
||||
|
||||
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
|
||||
final BytecodeEnhancementMetadata bytecodeEnhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
|
||||
if ( bytecodeEnhancementMetadata.isEnhancedForLazyLoading() ) {
|
||||
final BytecodeEnhancementMetadata enhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
|
||||
if ( enhancementMetadata.isEnhancedForLazyLoading() ) {
|
||||
|
||||
// if the entity defines a HibernateProxy factory, see if there is an
|
||||
// existing proxy associated with the PC - and if so, use it
|
||||
|
@ -331,10 +331,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
LOG.debug( "Creating a HibernateProxy for to-one association with subclasses to honor laziness" );
|
||||
return createProxy( entityKey );
|
||||
}
|
||||
return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this );
|
||||
return enhancementMetadata.createEnhancedProxy( entityKey, false, this );
|
||||
}
|
||||
else if ( !entityMetamodel.hasSubclasses() ) {
|
||||
return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this );
|
||||
return enhancementMetadata.createEnhancedProxy( entityKey, false, this );
|
||||
}
|
||||
// If we get here, then the entity class has subclasses and there is no HibernateProxy factory.
|
||||
// The entity will get loaded below.
|
||||
|
@ -374,16 +374,16 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
@Override
|
||||
public void fetch(Object association) {
|
||||
checkOpen();
|
||||
PersistenceContext persistenceContext = getPersistenceContext();
|
||||
final PersistenceContext persistenceContext = getPersistenceContext();
|
||||
final LazyInitializer initializer = extractLazyInitializer( association );
|
||||
if ( initializer != null ) {
|
||||
if ( initializer.isUninitialized() ) {
|
||||
String entityName = initializer.getEntityName();
|
||||
Object id = initializer.getIdentifier();
|
||||
initializer.setSession(this);
|
||||
final String entityName = initializer.getEntityName();
|
||||
final Object id = initializer.getIdentifier();
|
||||
initializer.setSession( this );
|
||||
persistenceContext.beforeLoad();
|
||||
try {
|
||||
Object entity = initializer.getImplementation(); //forces the load to occur
|
||||
final Object entity = initializer.getImplementation(); //forces the load to occur
|
||||
if ( entity==null ) {
|
||||
getFactory().getEntityNotFoundDelegate().handleEntityNotFound( entityName, id );
|
||||
}
|
||||
|
@ -399,9 +399,9 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
}
|
||||
}
|
||||
else if ( isPersistentAttributeInterceptable( association ) ) {
|
||||
final PersistentAttributeInterceptor interceptor =
|
||||
asPersistentAttributeInterceptable( association ).$$_hibernate_getInterceptor();
|
||||
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor) {
|
||||
final PersistentAttributeInterceptable interceptable = asPersistentAttributeInterceptable( association );
|
||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
|
||||
final EnhancementAsProxyLazinessInterceptor proxyInterceptor =
|
||||
(EnhancementAsProxyLazinessInterceptor) interceptor;
|
||||
proxyInterceptor.setSession( this );
|
||||
|
@ -419,18 +419,16 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
else if ( association instanceof PersistentCollection ) {
|
||||
final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) association;
|
||||
if ( !persistentCollection.wasInitialized() ) {
|
||||
|
||||
final CollectionPersister collectionDescriptor = getFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
final CollectionPersister collectionDescriptor = getFactory().getMappingMetamodel()
|
||||
.getCollectionDescriptor( persistentCollection.getRole() );
|
||||
final Object key = persistentCollection.getKey();
|
||||
persistenceContext.addUninitializedCollection( collectionDescriptor, persistentCollection, key );
|
||||
persistentCollection.setCurrentSession(this);
|
||||
persistentCollection.setCurrentSession( this );
|
||||
try {
|
||||
collectionDescriptor.initialize( key, this );
|
||||
}
|
||||
finally {
|
||||
persistentCollection.unsetSession(this);
|
||||
persistentCollection.unsetSession( this );
|
||||
if ( persistenceContext.isLoadFinished() ) {
|
||||
persistenceContext.clear();
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SingleIdEntityLoaderProvidedQueryImpl<T> implements SingleIdEntityL
|
|||
Boolean readOnly,
|
||||
SharedSessionContractImplementor session) {
|
||||
if ( entityInstance != null ) {
|
||||
throw new UnsupportedOperationException( );
|
||||
throw new UnsupportedOperationException("null entity instance");
|
||||
}
|
||||
return load( pkValue, lockOptions, readOnly, session );
|
||||
}
|
||||
|
|
|
@ -861,6 +861,7 @@ public class NativeQueryImpl<R>
|
|||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResultTypeClass(Class<?> resultClass) {
|
||||
assert resultSetMapping.getNumberOfResultBuilders() == 0;
|
||||
registerBuilder( Builders.resultClassBuilder( resultClass, getSessionFactory() ) );
|
||||
|
|
|
@ -315,5 +315,6 @@ public interface NativeQueryImplementor<R> extends QueryImplementor<R>, NativeQu
|
|||
@Override
|
||||
NativeQueryImplementor<R> setProperties(@SuppressWarnings("rawtypes") Map bean);
|
||||
|
||||
void addResultTypeClass(Class<?> resultClass);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue