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


Java CriteriaImpl类代码示例

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


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

示例1: createAssociationPathCriteriaMap

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
private void createAssociationPathCriteriaMap() {
	Iterator iter = rootCriteria.iterateSubcriteria();
	while ( iter.hasNext() ) {
		CriteriaImpl.Subcriteria crit = ( CriteriaImpl.Subcriteria ) iter.next();
		String wholeAssociationPath = getWholeAssociationPath( crit );
		Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit );
		if ( old != null ) {
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
		int joinType = crit.getJoinType();
		old = associationPathJoinTypesMap.put( wholeAssociationPath, new Integer( joinType ) );
		if ( old != null ) {
			// TODO : not so sure this is needed...
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:CriteriaQueryTranslator.java

示例2: queryCount

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public int queryCount(DetachedCriteria detachedCriteria, String dataSourceName) {
	Session session = this.getSessionFactory(dataSourceName).openSession();
	try {
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		try {
			Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
			field.setAccessible(true);
			field.set(criteria, new ArrayList());
		} catch (Exception e) {
			e.printStackTrace();
		}
		int totalCount = 0;
		Object totalObject = criteria.setProjection(Projections.rowCount()).uniqueResult();
		if (totalObject instanceof Integer) {
			totalCount = (Integer) totalObject;
		} else if (totalObject instanceof Long) {
			totalCount = ((Long) totalObject).intValue();
		} else if (totalObject != null) {
			throw new RuntimeException("Can not convert [" + totalObject
					+ "] to a int value when query entity total count!");
		}
		return totalCount;
	} finally {
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:29,代码来源:HibernateDao.java

示例3: toSqlString

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
	
	final SessionImplementor session = ( (CriteriaImpl) criteria ).getSession(); //ugly!
	final SessionFactoryImplementor factory = session.getFactory();
	
	final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
	CriteriaQueryTranslator innerQuery = new CriteriaQueryTranslator( 
			factory, 
			criteriaImpl, 
			criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union) 
			criteriaQuery.generateSQLAlias(),
			criteriaQuery
		);
	
	params = innerQuery.getQueryParameters(); //TODO: bad lifecycle....
	types = innerQuery.getProjectedTypes();
	
	//String filter = persister.filterFragment( innerQuery.getRootSQLALias(), session.getEnabledFilters() );
	
	String sql = new Select( factory.getDialect() )
		.setWhereClause( innerQuery.getWhereCondition() )
		.setGroupByClause( innerQuery.getGroupBy() )
		.setSelectClause( innerQuery.getSelect() )
		.setFromClause(
				persister.fromTableFragment( innerQuery.getRootSQLALias() ) +   
				persister.fromJoinFragment( innerQuery.getRootSQLALias(), true, false )
			)
		.toStatementString();
	
	final StringBuffer buf = new StringBuffer()
		.append( toLeftSqlString(criteria, criteriaQuery) );
	if (op!=null) buf.append(' ').append(op).append(' ');
	if (quantifier!=null) buf.append(quantifier).append(' ');
	return buf.append('(').append(sql).append(')')
		.toString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:SubqueryExpression.java

示例4: CriteriaJoinWalker

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public CriteriaJoinWalker(
		final OuterJoinLoadable persister, 
		final CriteriaQueryTranslator translator,
		final SessionFactoryImplementor factory, 
		final CriteriaImpl criteria, 
		final String rootEntityName,
		final Map enabledFilters)
throws HibernateException {
	super(persister, factory, enabledFilters);

	this.translator = translator;

	querySpaces = translator.getQuerySpaces();

	if ( translator.hasProjection() ) {
		resultTypes = translator.getProjectedTypes();
		
		initProjection( 
				translator.getSelect(), 
				translator.getWhereCondition(), 
				translator.getOrderBy(),
				translator.getGroupBy(),
				LockMode.NONE 
			);
	}
	else {
		resultTypes = new Type[] { TypeFactory.manyToOne( persister.getEntityName() ) };

		initAll( translator.getWhereCondition(), translator.getOrderBy(), LockMode.NONE );
	}
	
	userAliasList.add( criteria.getAlias() ); //root entity comes *last*
	userAliases = ArrayHelper.toStringArray(userAliasList);

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:CriteriaJoinWalker.java

示例5: CriteriaLoader

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public CriteriaLoader(
		final OuterJoinLoadable persister,
		final SessionFactoryImplementor factory,
		final CriteriaImpl criteria,
		final String rootEntityName,
		final Map enabledFilters)
throws HibernateException {
	super(factory, enabledFilters);

	translator = new CriteriaQueryTranslator(
			factory,
			criteria,
			rootEntityName,
			CriteriaQueryTranslator.ROOT_SQL_ALIAS
		);

	querySpaces = translator.getQuerySpaces();

	CriteriaJoinWalker walker = new CriteriaJoinWalker(
			persister,
			translator,
			factory,
			criteria,
			rootEntityName,
			enabledFilters
		);

	initFromWalker(walker);

	userAliases = walker.getUserAliases();
	resultTypes = walker.getResultTypes();

	postInstantiate();

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:CriteriaLoader.java

示例6: CriteriaQueryTranslator

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public CriteriaQueryTranslator(
		final SessionFactoryImplementor factory,
        final CriteriaImpl criteria,
        final String rootEntityName,
        final String rootSQLAlias,
        CriteriaQuery outerQuery) throws HibernateException {
	this( factory, criteria, rootEntityName, rootSQLAlias );
	outerQueryTranslator = outerQuery;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:10,代码来源:CriteriaQueryTranslator.java

示例7: getWholeAssociationPath

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
private String getWholeAssociationPath(CriteriaImpl.Subcriteria subcriteria) {
	String path = subcriteria.getPath();

	// some messy, complex stuff here, since createCriteria() can take an
	// aliased path, or a path rooted at the creating criteria instance
	Criteria parent = null;
	if ( path.indexOf( '.' ) > 0 ) {
		// if it is a compound path
		String testAlias = StringHelper.root( path );
		if ( !testAlias.equals( subcriteria.getAlias() ) ) {
			// and the qualifier is not the alias of this criteria
			//      -> check to see if we belong to some criteria other
			//          than the one that created us
			parent = ( Criteria ) aliasCriteriaMap.get( testAlias );
		}
	}
	if ( parent == null ) {
		// otherwise assume the parent is the the criteria that created us
		parent = subcriteria.getParent();
	}
	else {
		path = StringHelper.unroot( path );
	}

	if ( parent.equals( rootCriteria ) ) {
		// if its the root criteria, we are done
		return path;
	}
	else {
		// otherwise, recurse
		return getWholeAssociationPath( ( CriteriaImpl.Subcriteria ) parent ) + '.' + path;
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:34,代码来源:CriteriaQueryTranslator.java

示例8: getWhereCondition

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public String getWhereCondition() {
	StringBuffer condition = new StringBuffer( 30 );
	Iterator criterionIterator = rootCriteria.iterateExpressionEntries();
	while ( criterionIterator.hasNext() ) {
		CriteriaImpl.CriterionEntry entry = ( CriteriaImpl.CriterionEntry ) criterionIterator.next();
		String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
		condition.append( sqlString );
		if ( criterionIterator.hasNext() ) {
			condition.append( " and " );
		}
	}
	return condition.toString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:14,代码来源:CriteriaQueryTranslator.java

示例9: getOrderBy

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public String getOrderBy() {
	StringBuffer orderBy = new StringBuffer( 30 );
	Iterator criterionIterator = rootCriteria.iterateOrderings();
	while ( criterionIterator.hasNext() ) {
		CriteriaImpl.OrderEntry oe = ( CriteriaImpl.OrderEntry ) criterionIterator.next();
		orderBy.append( oe.getOrder().toSqlString( oe.getCriteria(), this ) );
		if ( criterionIterator.hasNext() ) {
			orderBy.append( ", " );
		}
	}
	return orderBy.toString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:13,代码来源:CriteriaQueryTranslator.java

示例10: getPage

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
/**
 * Get Page, apply filter if any.
 * If Filter is a entity model, use Example to create a criteria.
 * else enable filter by name on session. 
 * @param page with page definitions
 * @return page of results
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <K> Page<K> getPage(Page<K> page) {
	
	List data = null;
	// try named query
	Query query = getQuery(page);
	if (query != null) {
		data = query.list();
	}
	else {
		// try filter, example and criteria builders
		Criteria criteria = getCriteria(page);
		ResultTransformer rt = ((CriteriaImpl) criteria).getResultTransformer(); 
		criteria.setProjection(Projections.rowCount());
		 page.setCount(((Long) criteria.uniqueResult()).intValue());
		// reset criteria
		criteria.setProjection(null);
		criteria.setResultTransformer(rt);
		// set start index and page size
		criteria.setFirstResult(page.getStartIndex())
			.setMaxResults(page.getPageSize());
		applyOrder(page, criteria);
		// run it
		criteria.setCacheable(cachePageQueries);
		data = criteria.list();
	}
	
	page.setData(data);
	
	return page;
}
 
开发者ID:chelu,项目名称:jdal,代码行数:39,代码来源:HibernateDao.java

示例11: findAliasForPropertyPath

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
/**
 * Return a existing alias for propertyPath on Criteria or null if none
 * @param criteria Hibernate Criteria
 * @param propertyPath the property path
 * @return alias or null if none
 */
public static String findAliasForPropertyPath(Criteria criteria, String propertyPath) {
	CriteriaImpl c = (CriteriaImpl) criteria;
	Iterator iter = c.iterateSubcriteria();
	while (iter.hasNext()) {
		Subcriteria subCriteria = (Subcriteria) iter.next();
		if (propertyPath.equals(subCriteria.getPath()));
			return subCriteria.getAlias();
	}
	// not found
	return null; 
}
 
开发者ID:chelu,项目名称:jdal,代码行数:18,代码来源:HibernateUtils.java

示例12: DetachedCriteria

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
protected DetachedCriteria(String entityName) {
	impl = new CriteriaImpl(entityName, null);
	criteria = impl;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:5,代码来源:DetachedCriteria.java

示例13: getCriteriaImpl

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
CriteriaImpl getCriteriaImpl() {
	return impl;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:DetachedCriteria.java

示例14: getRootCriteria

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public CriteriaImpl getRootCriteria() {
	return rootCriteria;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:CriteriaQueryTranslator.java

示例15: JazzDetachedCriteria

import org.hibernate.impl.CriteriaImpl; //导入依赖的package包/类
public JazzDetachedCriteria(CriteriaImpl impl, Criteria criteria) {
	super(impl, criteria);
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:4,代码来源:JazzDetachedCriteria.java


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