org.hibernate.engine.spi.SessionFactoryImplementor Java Examples

The following examples show how to use org.hibernate.engine.spi.SessionFactoryImplementor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IgniteTestHelper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory, AssociationStorageType type) {
	int asscociationCount = 0;
	Set<IgniteCache<Object, BinaryObject>> processedCaches = Collections.newSetFromMap( new IdentityHashMap<IgniteCache<Object, BinaryObject>, Boolean>() );

	for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) {
		AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata();
		IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata );
		if ( !processedCaches.contains( associationCache ) ) {
			asscociationCount += associationCache.size();
			processedCaches.add( associationCache );
		}
	}

	return asscociationCount;
}
 
Example #2
Source File: PessimisticReadSelectLockingStrategy.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected String generateLockString(int lockTimeout) {
	final SessionFactoryImplementor factory = getLockable().getFactory();
	final LockOptions lockOptions = new LockOptions( getLockMode() );
	lockOptions.setTimeOut( lockTimeout );
	final SimpleSelect select = new SimpleSelect( factory.getDialect() )
			.setLockOptions( lockOptions )
			.setTableName( getLockable().getRootTableName() )
			.addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
			.addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
	if ( getLockable().isVersioned() ) {
		select.addCondition( getLockable().getVersionColumnName(), "=?" );
	}
	if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
	}
	return select.toStatementString();
}
 
Example #3
Source File: PostgreSQLPlainToTSQueryFunction.java    From JuniperBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) throws QueryException {
    if (arguments == null || arguments.size() < 2) {
        throw new IllegalArgumentException("The function must be passed 2 arguments");
    }

    String fragment;
    String ftsConfig;
    String field;
    String value;
    if (arguments.size() == 3) {
        ftsConfig = (String) arguments.get(0);
        field = (String) arguments.get(1);
        value = (String) arguments.get(2);
        fragment = field + " @@ plainto_tsquery(" + ftsConfig + ", " + value + ")";
    } else {
        field = (String) arguments.get(0);
        value = (String) arguments.get(1);
        fragment = field + " @@ plainto_tsquery(" + value + ")";
    }
    return fragment;
}
 
Example #4
Source File: ReactiveOneToManyLoader.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ReactiveOneToManyLoader(
		QueryableCollection oneToManyPersister,
		int batchSize,
		String subquery,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	super(oneToManyPersister, factory, loadQueryInfluencers);

	initFromWalker( new OneToManyJoinWalker(
			oneToManyPersister,
			batchSize,
			subquery,
			factory,
			loadQueryInfluencers
	) );

	postInstantiate();
	if (LOG.isDebugEnabled()) {
		LOG.debugf("Static select for one-to-many %s: %s", oneToManyPersister.getRole(), getSQLString());
	}
}
 
Example #5
Source File: FieldToBeanResultTransformer.java    From ueboot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Object transformTuple(Object tuple[], String aliases[]) {
    try {
        if (!this.isInitialized) {
            this.initialize(aliases);
        } else {
            this.check(aliases);
        }

        Object result = this.resultClass.newInstance();

        for (int i = 0; i < aliases.length; ++i) {
            if (this.setters[i] != null) {
                this.setters[i].set(result, tuple[i], (SessionFactoryImplementor) null);
            }
        }

        return result;
    } catch (InstantiationException var5) {
        throw new HibernateException("Could not instantiate resultclass: " + this.resultClass.getName());
    } catch (IllegalAccessException var6) {
        throw new HibernateException("Could not instantiate resultclass: " + this.resultClass.getName());
    }
}
 
Example #6
Source File: ConditionalParenthesisFunction.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
	final boolean hasArgs = !arguments.isEmpty();
	final StringBuilder buf = new StringBuilder( getName() );
	if ( hasArgs ) {
		buf.append( "(" );
		for ( int i = 0; i < arguments.size(); i++ ) {
			buf.append( arguments.get( i ) );
			if ( i < arguments.size() - 1 ) {
				buf.append( ", " );
			}
		}
		buf.append( ")" );
	}
	return buf.toString();
}
 
Example #7
Source File: ReactiveDynamicBatchingCollectionInitializer.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ReactiveDynamicBatchingCollectionInitializer(
		QueryableCollection collectionPersister,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers influencers) {
	super( collectionPersister, factory, influencers );

	JoinWalker walker = buildJoinWalker( collectionPersister, factory, influencers );
	initFromWalker( walker );
	this.sqlTemplate = walker.getSQLString();
	this.alias = StringHelper.generateAlias( collectionPersister.getRole(), 0 );
	postInstantiate();

	if ( LOG.isDebugEnabled() ) {
		LOG.debugf(
				"SQL-template for dynamic collection [%s] batch-fetching : %s",
				collectionPersister.getRole(),
				sqlTemplate
		);
	}
}
 
Example #8
Source File: IgniteTestHelper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Map<String, Object> extractEntityTuple(Session session, EntityKey key) {
	SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) session.getSessionFactory();
	IgniteCache<Object, BinaryObject> cache = getEntityCache( sessionFactory, key.getMetadata() );
	Object cacheKey = getProvider( sessionFactory ).createKeyObject( key );

	Map<String, Object> result = new HashMap<>();
	BinaryObject po = cache.get( cacheKey );

	TupleSnapshot snapshot = new IgniteTupleSnapshot( cacheKey, po, key.getMetadata() );
	for ( String fieldName : snapshot.getColumnNames() ) {
		result.put( fieldName, snapshot.get( fieldName ) );
	}

	return result;
}
 
Example #9
Source File: MySQLTriggerBasedJsonAuditLogTest.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
private void setCurrentLoggedUser(EntityManager entityManager) {
    Session session = entityManager.unwrap(Session.class);
    Dialect dialect = session.getSessionFactory().unwrap(SessionFactoryImplementor.class).getJdbcServices().getDialect();
    String loggedUser = ReflectionUtils.invokeMethod(
        dialect,
        "escapeLiteral",
        LoggedUser.get()
    );

    session.doWork(connection -> {
        update(
            connection,
            String.format(
                "SET @logged_user = '%s'", loggedUser
            )
        );
    });
}
 
Example #10
Source File: CollectionType.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected String renderLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException {
	if ( !Hibernate.isInitialized( value ) ) {
		return "<uninitialized>";
	}

	final List<String> list = new ArrayList<>();
	Type elemType = getElementType( factory );
	Iterator itr = getElementsIterator( value );
	while ( itr.hasNext() ) {
		Object element = itr.next();
		if ( element == LazyPropertyInitializer.UNFETCHED_PROPERTY || !Hibernate.isInitialized( element ) ) {
			list.add( "<uninitialized>" );
		}
		else {
			list.add( elemType.toLoggableString( element, factory ) );
		}
	}
	return list.toString();
}
 
Example #11
Source File: DefaultReactiveLoadEventListener.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
private CompletionStage<Void> checkIdClass(
		final EntityPersister persister,
		final LoadEvent event,
		final LoadEventListener.LoadType loadType,
		final Class<?> idClass) {
	// we may have the kooky jpa requirement of allowing find-by-id where
	// "id" is the "simple pk value" of a dependent objects parent.  This
	// is part of its generally goofy "derived identity" "feature"
	final IdentifierProperty identifierProperty = persister.getEntityMetamodel().getIdentifierProperty();
	if ( identifierProperty.isEmbedded() ) {
		final EmbeddedComponentType dependentIdType = (EmbeddedComponentType) identifierProperty.getType();
		if ( dependentIdType.getSubtypes().length == 1 ) {
			final Type singleSubType = dependentIdType.getSubtypes()[0];
			if ( singleSubType.isEntityType() ) {
				final EntityType dependentParentType = (EntityType) singleSubType;
				final SessionFactoryImplementor factory = event.getSession().getFactory();
				final Type dependentParentIdType = dependentParentType.getIdentifierOrUniqueKeyType( factory );
				if ( dependentParentIdType.getReturnedClass().isInstance( event.getEntityId() ) ) {
					// yep that's what we have...
					return loadByDerivedIdentitySimplePkValue( event, loadType, persister,
							dependentIdType, factory.getMetamodel().entityPersister( dependentParentType.getAssociatedEntityName() )
					);
				}
			}
		}
	}
	throw new TypeMismatchException(
			"Provided id of the wrong type for class " + persister.getEntityName() + ". Expected: " + idClass + ", got " + event.getEntityId().getClass() );
}
 
Example #12
Source File: AbstractEntityTuplizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static Serializable determineEntityId(
		Object entity,
		AssociationType associationType,
		SharedSessionContractImplementor session,
		SessionFactoryImplementor sessionFactory) {
	if ( entity == null ) {
		return null;
	}

	if ( HibernateProxy.class.isInstance( entity ) ) {
		// entity is a proxy, so we know it is not transient; just return ID from proxy
		return ( (HibernateProxy) entity ).getHibernateLazyInitializer().getIdentifier();
	}

	if ( session != null ) {
		final EntityEntry pcEntry = session.getPersistenceContext().getEntry( entity );
		if ( pcEntry != null ) {
			// entity managed; return ID.
			return pcEntry.getId();
		}
	}

	final EntityPersister persister = resolveEntityPersister(
			entity,
			associationType,
			session,
			sessionFactory
	);

	return persister.getIdentifier( entity, session );
}
 
Example #13
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CollectionInitializer createRealBatchingOneToManyInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize );
	final Loader[] loaders = new Loader[ batchSizes.length ];
	for ( int i = 0; i < batchSizes.length; i++ ) {
		loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers );
	}
	return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #14
Source File: PaddedBatchingEntityLoaderBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected UniqueEntityLoader buildBatchingLoader(
		OuterJoinLoadable persister,
		int batchSize,
		LockMode lockMode,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers influencers) {
	return new PaddedBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers );
}
 
Example #15
Source File: JdbcResultMetadata.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public JdbcResultMetadata(SessionFactoryImplementor factory, ResultSet resultSet) throws HibernateException {
	try {
		this.factory = factory;
		this.resultSet = resultSet;
		this.resultSetMetaData = resultSet.getMetaData();
	}
	catch( SQLException e ) {
		throw new HibernateException( "Could not extract result set metadata", e );
	}
}
 
Example #16
Source File: MessageHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate an info message string relating to a particular entity.
 *
 * @param persister The persister for the entity
 * @param id The entity id value
 * @param factory The session factory - Could be null!
 * @return An info string, in the form [FooBar#1]
 */
public static String infoString(
		EntityPersister persister,
		Object id, 
		SessionFactoryImplementor factory) {
	StringBuilder s = new StringBuilder();
	s.append( '[' );
	Type idType;
	if( persister == null ) {
		s.append( "<null EntityPersister>" );
		idType = null;
	}
	else {
		s.append( persister.getEntityName() );
		idType = persister.getIdentifierType();
	}
	s.append( '#' );

	if ( id == null ) {
		s.append( "<null>" );
	}
	else {
		if ( idType == null ) {
			s.append( id );
		}
		else {
			if ( factory != null ) {
				s.append( idType.toLoggableString( id, factory ) );
			}
			else {
				s.append( "<not loggable>" );
			}
		}
	}
	s.append( ']' );

	return s.toString();

}
 
Example #17
Source File: SubqueryExpression.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	//the following two lines were added to ensure that this.params is not null, which
	//can happen with two-deep nested subqueries
	final SessionFactoryImplementor factory = criteriaQuery.getFactory();
	createAndSetInnerQuery( criteriaQuery, factory );

	final Type[] ppTypes = params.getPositionalParameterTypes();
	final Object[] ppValues = params.getPositionalParameterValues();
	final TypedValue[] tv = new TypedValue[ppTypes.length];
	for ( int i=0; i<ppTypes.length; i++ ) {
		tv[i] = new TypedValue( ppTypes[i], ppValues[i] );
	}
	return tv;
}
 
Example #18
Source File: DeleteHandlerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public DeleteHandlerImpl(
		SessionFactoryImplementor factory,
		HqlSqlWalker walker,
		IdTableInfo idTableInfo) {
	super( factory, walker, idTableInfo );
	this.idTableInfo = idTableInfo;
}
 
Example #19
Source File: ComponentType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getHashCode(final Object x, final SessionFactoryImplementor factory) {
	int result = 17;
	for ( int i = 0; i < propertySpan; i++ ) {
		Object y = getPropertyValue( x, i );
		result *= 37;
		if ( y != null ) {
			result += propertyTypes[i].getHashCode( y, factory );
		}
	}
	return result;
}
 
Example #20
Source File: QueryParameterBindingsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private QueryParameterBindingsImpl(
		SessionFactoryImplementor sessionFactory,
		ParameterMetadata parameterMetadata,
		boolean queryParametersValidationEnabled) {
	this.sessionFactory = sessionFactory;
	this.parameterMetadata = parameterMetadata;
	this.queryParametersValidationEnabled = queryParametersValidationEnabled;

	this.parameterBindingMap = CollectionHelper.concurrentMap( parameterMetadata.getParameterCount() );

	this.jdbcStyleOrdinalCountBase = sessionFactory.getSessionFactoryOptions().jdbcStyleParamsZeroBased() ? 0 : 1;

	if ( parameterMetadata.hasPositionalParameters() ) {
		int smallestOrdinalParamLabel = Integer.MAX_VALUE;
		for ( QueryParameter queryParameter : parameterMetadata.getPositionalParameters() ) {
			if ( queryParameter.getPosition() == null ) {
				throw new HibernateException( "Non-ordinal parameter ended up in ordinal param list" );
			}

			if ( queryParameter.getPosition() < smallestOrdinalParamLabel ) {
				smallestOrdinalParamLabel = queryParameter.getPosition();
			}
		}
		ordinalParamValueOffset = smallestOrdinalParamLabel;
	}
	else {
		ordinalParamValueOffset = 0;
	}
}
 
Example #21
Source File: AbstractEntityTuplizer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static MappedIdentifierValueMarshaller buildMappedIdentifierValueMarshaller(
		String entityName,
		SessionFactoryImplementor sessionFactory,
		ComponentType mappedIdClassComponentType,
		ComponentType virtualIdComponent) {
	// so basically at this point we know we have a "mapped" composite identifier
	// which is an awful way to say that the identifier is represented differently
	// in the entity and in the identifier value.  The incoming value should
	// be an instance of the mapped identifier class (@IdClass) while the incoming entity
	// should be an instance of the entity class as defined by metamodel.
	//
	// However, even within that we have 2 potential scenarios:
	//		1) @IdClass types and entity @Id property types match
	//			- return a NormalMappedIdentifierValueMarshaller
	//		2) They do not match
	//			- return a IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller
	boolean wereAllEquivalent = true;
	// the sizes being off is a much bigger problem that should have been caught already...
	for ( int i = 0; i < virtualIdComponent.getSubtypes().length; i++ ) {
		if ( virtualIdComponent.getSubtypes()[i].isEntityType()
				&& !mappedIdClassComponentType.getSubtypes()[i].isEntityType() ) {
			wereAllEquivalent = false;
			break;
		}
	}

	return wereAllEquivalent ?
			new NormalMappedIdentifierValueMarshaller( virtualIdComponent, mappedIdClassComponentType ) :
			new IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller(
					entityName,
					sessionFactory,
					virtualIdComponent,
					mappedIdClassComponentType
	);
}
 
Example #22
Source File: IgniteQueryParserService.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public QueryParsingResult parseQuery(SessionFactoryImplementor sessionFactory, String queryString, Map<String, Object> namedParameters) {
	QueryParser queryParser = new QueryParser();
	IgniteProcessingChain processingChain = new IgniteProcessingChain( sessionFactory, getDefinedEntityNames( sessionFactory ), namedParameters );
	IgniteQueryParsingResult result = queryParser.parseQuery( queryString, processingChain );

	return result;
}
 
Example #23
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollectionInitializer createRealBatchingOneToManyInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize );
	final Loader[] loaders = new Loader[ batchSizes.length ];
	for ( int i = 0; i < batchSizes.length; i++ ) {
		loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers );
	}
	return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #24
Source File: StandardAnsiSqlAggregationFunctions.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) {
	if ( arguments.size() > 1 ) {
		if ( "distinct".equalsIgnoreCase( arguments.get( 0 ).toString() ) ) {
			return renderCountDistinct( arguments, factory.getDialect() );
		}
	}
	return super.render( firstArgumentType, arguments, factory );
}
 
Example #25
Source File: BatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds a batch-fetch capable CollectionInitializer for basic and many-to-many collections (collections with
 * a dedicated collection table).
 *
 * @param persister THe collection persister
 * @param maxBatchSize The maximum number of keys to batch-fetch together
 * @param factory The SessionFactory
 * @param influencers Any influencers that should affect the built query
 *
 * @return The batch-fetch capable collection initializer
 */
public CollectionInitializer createBatchingCollectionInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers influencers) {
	if ( maxBatchSize <= 1 ) {
		// no batching
		return buildNonBatchingLoader( persister, factory, influencers );
	}

	return createRealBatchingCollectionInitializer( persister, maxBatchSize, factory, influencers );
}
 
Example #26
Source File: ReactiveHQLQueryPlan.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ReactiveHQLQueryPlan(
		String hql,
		String collectionRole,
		boolean shallow,
		Map<String, Filter> enabledFilters,
		SessionFactoryImplementor factory,
		EntityGraphQueryHint entityGraphQueryHint) {
	super( hql, collectionRole, shallow, enabledFilters, factory, entityGraphQueryHint );
}
 
Example #27
Source File: PostgreSQLFTSFunction.java    From blog-tutorials with MIT License 5 votes vote down vote up
@Override
public String render(Type type, List args, SessionFactoryImplementor factory) throws QueryException {

	if (args == null || args.size() != 3) {
		throw new IllegalArgumentException("The function must be passed 2 arguments");
	}

	String language = (String) args.get(0);
	String field = (String) args.get(1);
	String searchString = (String) args.get(2);
	return field + " @@ to_tsquery('" + language + "', " + searchString + ")";
}
 
Example #28
Source File: QueryPlanCache.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs the QueryPlanCache to be used by the given SessionFactory
 *
 * @param factory The SessionFactory
 */
@SuppressWarnings("deprecation")
public QueryPlanCache(final SessionFactoryImplementor factory) {
	this.factory = factory;

	Integer maxParameterMetadataCount = ConfigurationHelper.getInteger(
			Environment.QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE,
			factory.getProperties()
	);
	if ( maxParameterMetadataCount == null ) {
		maxParameterMetadataCount = ConfigurationHelper.getInt(
				Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES,
				factory.getProperties(),
				DEFAULT_PARAMETER_METADATA_MAX_COUNT
		);
	}
	Integer maxQueryPlanCount = ConfigurationHelper.getInteger(
			Environment.QUERY_PLAN_CACHE_MAX_SIZE,
			factory.getProperties()
	);
	if ( maxQueryPlanCount == null ) {
		maxQueryPlanCount = ConfigurationHelper.getInt(
				Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES,
				factory.getProperties(),
				DEFAULT_QUERY_PLAN_MAX_COUNT
		);
	}

	queryPlanCache = new BoundedConcurrentHashMap( maxQueryPlanCount, 20, BoundedConcurrentHashMap.Eviction.LIRS );
	parameterMetadataCache = new BoundedConcurrentHashMap<>(
			maxParameterMetadataCount,
			20,
			BoundedConcurrentHashMap.Eviction.LIRS
	);

	nativeQueryInterpreter = factory.getServiceRegistry().getService( NativeQueryInterpreter.class );
}
 
Example #29
Source File: OneToManyJoinWalker.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public OneToManyJoinWalker(
		QueryableCollection oneToManyPersister,
		int batchSize,
		String subquery,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	super( factory, loadQueryInfluencers );

	this.oneToManyPersister = oneToManyPersister;

	final OuterJoinLoadable elementPersister = (OuterJoinLoadable) oneToManyPersister.getElementPersister();
	final String alias = generateRootAlias( oneToManyPersister.getRole() );

	walkEntityTree( elementPersister, alias );

	List allAssociations = new ArrayList();
	allAssociations.addAll( associations );
	allAssociations.add(
			OuterJoinableAssociation.createRoot(
					oneToManyPersister.getCollectionType(),
					alias,
					getFactory()
			)
	);
	initPersisters( allAssociations, LockMode.NONE );
	initStatementString( elementPersister, alias, batchSize, subquery );
}
 
Example #30
Source File: EntityBasedAssociationAttribute.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EntityBasedAssociationAttribute(
		EntityPersister source,
		SessionFactoryImplementor sessionFactory,
		int attributeNumber,
		String attributeName,
		AssociationType attributeType,
		BaselineAttributeInformation baselineInfo) {
	super( source, sessionFactory, attributeNumber, attributeName, attributeType, baselineInfo );
}