当前位置: 首页>>代码示例>>Java>>正文


Java NaturalIdLoadAccess类代码示例

本文整理汇总了Java中org.hibernate.NaturalIdLoadAccess的典型用法代码示例。如果您正苦于以下问题:Java NaturalIdLoadAccess类的具体用法?Java NaturalIdLoadAccess怎么用?Java NaturalIdLoadAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NaturalIdLoadAccess类属于org.hibernate包,在下文中一共展示了NaturalIdLoadAccess类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: byNaturalId

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
@Override
public NaturalIdLoadAccess byNaturalId(String entityName) {
	return session.byNaturalId( entityName );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SessionDelegatorBaseImpl.java

示例2: byNaturalId

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
@Override
public NaturalIdLoadAccess byNaturalId(String entityName) {
	return new NaturalIdLoadAccessImpl( entityName );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SessionImpl.java

示例3: list

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
@Override
public List list(Criteria criteria) throws HibernateException {
	// TODO: Is this guaranteed to always be CriteriaImpl?
	CriteriaImpl criteriaImpl = (CriteriaImpl) criteria;
			
	final NaturalIdLoadAccess naturalIdLoadAccess = this.tryNaturalIdLoadAccess( criteriaImpl );
	if ( naturalIdLoadAccess != null ) {
		// EARLY EXIT!
		return Arrays.asList( naturalIdLoadAccess.load() );
	}

	errorIfClosed();
	checkTransactionSynchStatus();
	String[] implementors = factory.getImplementors( criteriaImpl.getEntityOrClassName() );
	int size = implementors.length;

	CriteriaLoader[] loaders = new CriteriaLoader[size];
	Set spaces = new HashSet();
	for( int i=0; i <size; i++ ) {

		loaders[i] = new CriteriaLoader(
				getOuterJoinLoadable( implementors[i] ),
				factory,
				criteriaImpl,
				implementors[i],
				getLoadQueryInfluencers()
			);

		spaces.addAll( loaders[i].getQuerySpaces() );

	}

	autoFlushIfRequired(spaces);

	List results = Collections.EMPTY_LIST;
	dontFlushFromFind++;
	boolean success = false;
	try {
		for( int i=0; i<size; i++ ) {
			final List currentResults = loaders[i].list(this);
			currentResults.addAll(results);
			results = currentResults;
		}
		success = true;
	}
	finally {
		dontFlushFromFind--;
		afterOperation(success);
		delayedAfterCompletion();
	}

	return results;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:54,代码来源:SessionImpl.java

示例4: tryNaturalIdLoadAccess

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
/**
 * Checks to see if the CriteriaImpl is a naturalId lookup that can be done via
 * NaturalIdLoadAccess
 *
 * @param criteria The criteria to check as a complete natural identifier lookup.
 *
 * @return A fully configured NaturalIdLoadAccess or null, if null is returned the standard CriteriaImpl execution
 *         should be performed
 */
private NaturalIdLoadAccess tryNaturalIdLoadAccess(CriteriaImpl criteria) {
	// See if the criteria lookup is by naturalId
	if ( !criteria.isLookupByNaturalKey() ) {
		return null;
	}

	final String entityName = criteria.getEntityOrClassName();
	final EntityPersister entityPersister = factory.getEntityPersister( entityName );

	// Verify the entity actually has a natural id, needed for legacy support as NaturalIdentifier criteria
	// queries did no natural id validation
	if ( !entityPersister.hasNaturalIdentifier() ) {
		return null;
	}

	// Since isLookupByNaturalKey is true there can be only one CriterionEntry and getCriterion() will
	// return an instanceof NaturalIdentifier
	final CriterionEntry criterionEntry = (CriterionEntry) criteria.iterateExpressionEntries().next();
	final NaturalIdentifier naturalIdentifier = (NaturalIdentifier) criterionEntry.getCriterion();

	final Map<String, Object> naturalIdValues = naturalIdentifier.getNaturalIdValues();
	final int[] naturalIdentifierProperties = entityPersister.getNaturalIdentifierProperties();

	// Verify the NaturalIdentifier criterion includes all naturalId properties, first check that the property counts match
	if ( naturalIdentifierProperties.length != naturalIdValues.size() ) {
		return null;
	}

	final String[] propertyNames = entityPersister.getPropertyNames();
	final NaturalIdLoadAccess naturalIdLoader = this.byNaturalId( entityName );

	// Build NaturalIdLoadAccess and in the process verify all naturalId properties were specified
	for ( int i = 0; i < naturalIdentifierProperties.length; i++ ) {
		final String naturalIdProperty = propertyNames[naturalIdentifierProperties[i]];
		final Object naturalIdValue = naturalIdValues.get( naturalIdProperty );

		if ( naturalIdValue == null ) {
			// A NaturalId property is missing from the critera query, can't use NaturalIdLoadAccess
			return null;
		}

		naturalIdLoader.using( naturalIdProperty, naturalIdValue );
	}

	// Critera query contains a valid naturalId, use the new API
	LOG.warn( "Session.byNaturalId(" + entityName
			+ ") should be used for naturalId queries instead of Restrictions.naturalId() from a Criteria" );

	return naturalIdLoader;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:60,代码来源:SessionImpl.java

示例5: using

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
@Override
public NaturalIdLoadAccess using(String attributeName, Object value) {
	naturalIdParameters.put( attributeName, value );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:SessionImpl.java

示例6: byNaturalId

import org.hibernate.NaturalIdLoadAccess; //导入依赖的package包/类
protected <P> NaturalIdLoadAccess byNaturalId(Class<P> entityClass) {
    return this.getSession().byNaturalId(entityClass);
}
 
开发者ID:jurgendl,项目名称:hql-builder,代码行数:4,代码来源:ServiceImpl.java


注:本文中的org.hibernate.NaturalIdLoadAccess类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。