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


Java QueryException类代码示例

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


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

示例1: getQueryableCollection

import org.hibernate.QueryException; //导入依赖的package包/类
protected QueryableCollection getQueryableCollection(
		String entityName,
		String propertyName,
		SessionFactoryImplementor factory) throws HibernateException {
	final PropertyMapping ownerMapping = (PropertyMapping) factory.getEntityPersister( entityName );
	final Type type = ownerMapping.toType( propertyName );
	if ( !type.isCollectionType() ) {
		throw new MappingException(
				"Property path [" + entityName + "." + propertyName + "] does not reference a collection"
		);
	}

	final String role = ( (CollectionType) type ).getRole();
	try {
		return (QueryableCollection) factory.getCollectionPersister( role );
	}
	catch ( ClassCastException cce ) {
		throw new QueryException( "collection role is not queryable: " + role );
	}
	catch ( Exception e ) {
		throw new QueryException( "collection role not found: " + role );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractEmptinessExpression.java

示例2: createAssociationPathCriteriaMap

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

示例3: validateLhs

import org.hibernate.QueryException; //导入依赖的package包/类
private void validateLhs(FromReferenceNode lhs) {
	// make sure the lhs is "assignable"...
	if ( !lhs.isResolved() ) {
		throw new UnsupportedOperationException( "cannot validate assignablity of unresolved node" );
	}

	if ( lhs.getDataType().isCollectionType() ) {
		throw new QueryException( "collections not assignable in update statements" );
	}
	else if ( lhs.getDataType().isComponentType() ) {
		throw new QueryException( "Components currently not assignable in update statements" );
	}
	else if ( lhs.getDataType().isEntityType() ) {
		// currently allowed...
	}

	// TODO : why aren't these the same?
	if ( lhs.getImpliedJoin() != null || lhs.getFromElement().isImplied() ) {
		throw new QueryException( "Implied join paths are not assignable in update statements" );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AssignmentSpecification.java

示例4: end

import org.hibernate.QueryException; //导入依赖的package包/类
public void end(QueryTranslatorImpl q) throws QueryException {
	ignoreInitialJoin = false;

	Type propertyType = getPropertyType();
	if ( propertyType != null && propertyType.isCollectionType() ) {
		collectionRole = ( ( CollectionType ) propertyType ).getRole();
		collectionName = q.createNameForCollection( collectionRole );
		prepareForIndex( q );
	}
	else {
		columns = currentColumns();
		setType();
	}

	//important!!
	continuation = false;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PathExpressionParser.java

示例5: toColumns

import org.hibernate.QueryException; //导入依赖的package包/类
public String[] toColumns(String alias, String propertyName) throws QueryException {
	//TODO: *two* hashmap lookups here is one too many...
	String[] columns = (String[]) columnsByPropertyPath.get(propertyName);
	if ( columns == null ) {
		throw propertyException( propertyName );
	}
	String[] formulaTemplates = (String[]) formulaTemplatesByPropertyPath.get(propertyName);
	String[] columnReaderTemplates = (String[]) columnReaderTemplatesByPropertyPath.get(propertyName);
	String[] result = new String[columns.length];
	for ( int i=0; i<columns.length; i++ ) {
		if ( columnReaderTemplates[i]==null ) {
			result[i] = StringHelper.replace( formulaTemplates[i], Template.TEMPLATE, alias );
		}
		else {
			result[i] = StringHelper.replace( columnReaderTemplates[i], Template.TEMPLATE, alias );
		}
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AbstractPropertyMapping.java

示例6: performScroll

import org.hibernate.QueryException; //导入依赖的package包/类
/**
 * Coordinates the efforts to perform a scroll across all the included query translators.
 *
 * @param queryParameters The query parameters
 * @param session The session
 *
 * @return The query result iterator
 *
 * @throws HibernateException Indicates a problem performing the query
 */
public ScrollableResults performScroll(
		QueryParameters queryParameters,
		SessionImplementor session) throws HibernateException {
	if ( TRACE_ENABLED ) {
		LOG.tracev( "Iterate: {0}", getSourceQuery() );
		queryParameters.traceParameters( session.getFactory() );
	}
	if ( translators.length != 1 ) {
		throw new QueryException( "implicit polymorphism not supported for scroll() queries" );
	}
	if ( queryParameters.getRowSelection().definesLimits() && translators[0].containsCollectionFetches() ) {
		throw new QueryException( "firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches" );
	}

	return translators[0].scroll( queryParameters, session );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:HQLQueryPlan.java

示例7: render

import org.hibernate.QueryException; //导入依赖的package包/类
@Override
public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException {
	final boolean threeArgs = args.size() > 2;
	final Object pattern = args.get( 0 );
	final Object string = args.get( 1 );
	final Object start = threeArgs ? args.get( 2 ) : null;

	final StringBuilder buf = new StringBuilder();
	if (threeArgs) {
		buf.append( '(' );
	}
	buf.append( "position(" ).append( pattern ).append( " in " );
	if (threeArgs) {
		buf.append( "substring(");
	}
	buf.append( string );
	if (threeArgs) {
		buf.append( ", " ).append( start ).append( ')' );
	}
	buf.append( ')' );
	if (threeArgs) {
		buf.append( '+' ).append( start ).append( "-1)" );
	}
	return buf.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:PositionSubstringFunction.java

示例8: createAssociationPathCriteriaMap

import org.hibernate.QueryException; //导入依赖的package包/类
private void createAssociationPathCriteriaMap() {
	final Iterator<CustomCriteriaImpl.Subcriteria> iter = rootCriteria.iterateSubcriteria();
	while ( iter.hasNext() ) {
		CustomCriteriaImpl.Subcriteria crit = iter.next();
		String wholeAssociationPath = getWholeAssociationPath( crit );
		Object old = associationPathCriteriaMap.put( wholeAssociationPath, crit );
		if ( old != null ) {
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
		JoinType joinType = crit.getJoinType();
		old = associationPathJoinTypesMap.put( wholeAssociationPath, joinType );
		if ( old != null ) {
			// TODO : not so sure this is needed...
			throw new QueryException( "duplicate association path: " + wholeAssociationPath );
		}
		if ( crit.getWithClause() != null ) {
			this.withClauseMap.put( wholeAssociationPath, crit.getWithClause() );
		}
	}
}
 
开发者ID:geodir,项目名称:Layer-Query,代码行数:21,代码来源:CustomCriteriaQueryTranslator.java

示例9: getElementName

import org.hibernate.QueryException; //导入依赖的package包/类
private String getElementName(PathExpressionParser.CollectionElement element, QueryTranslatorImpl q) throws QueryException {
	String name;
	if ( element.isOneToMany ) {
		name = element.alias;
	}
	else {
		Type type = element.elementType;
		if ( type.isEntityType() ) { //ie. a many-to-many
			String entityName = ( ( EntityType ) type ).getAssociatedEntityName();
			name = pathExpressionParser.continueFromManyToMany( entityName, element.elementColumns, q );
		}
		else {
			throw new QueryException( "illegally dereferenced collection element" );
		}
	}
	return name;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:WhereParser.java

示例10: render

import org.hibernate.QueryException; //导入依赖的package包/类
@Override
public String render(Type columnType, List args, SessionFactoryImplementor factory) throws QueryException {
	final boolean threeArgs = args.size() > 2;
	final Object pattern = args.get( 0 );
	final Object string = args.get( 1 );
	final Object start = threeArgs ? args.get( 2 ) : null;

	final StringBuilder buf = new StringBuilder();
	buf.append( "charindex(" ).append( pattern ).append( ", " );
	if (threeArgs) {
		buf.append( "right(" );
	}
	buf.append( string );
	if (threeArgs) {
		buf.append( ", char_length(" ).append( string ).append( ")-(" ).append( start ).append( "-1))" );
	}
	buf.append( ')' );
	return buf.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:CharIndexFunction.java

示例11: render

import org.hibernate.QueryException; //导入依赖的package包/类
@Override
public String render(Type columnType, List args, SessionFactoryImplementor factory) throws QueryException {
	if ( args.size()!=2 ) {
		throw new QueryException( "cast() requires two arguments; found : " + args.size() );
	}
	final String type = (String) args.get( 1 );
	final int[] sqlTypeCodes = factory.getTypeResolver().heuristicType( type ).sqlTypes( factory );
	if ( sqlTypeCodes.length!=1 ) {
		throw new QueryException("invalid Hibernate type for cast()");
	}
	String sqlType = factory.getDialect().getCastTypeName( sqlTypeCodes[0] );
	if ( sqlType == null ) {
		//TODO: never reached, since getExplicitHibernateTypeName() actually throws an exception!
		sqlType = type;
	}
	return "cast(" + args.get( 0 ) + " as " + sqlType + ')';
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:CastFunction.java

示例12: getReturnType

import org.hibernate.QueryException; //导入依赖的package包/类
@Override
public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
	int[] sqlTypes;
	try {
		sqlTypes = columnType.sqlTypes( mapping );
	}
	catch ( MappingException me ) {
		throw new QueryException( me );
	}

	if ( sqlTypes.length != 1 ) {
		throw new QueryException( "multi-column type in avg()" );
	}

	final int sqlType = sqlTypes[0];
	if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) {
		return StandardBasicTypes.FLOAT;
	}
	else {
		return columnType;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ClassicAvgFunction.java

示例13: requireQueryableCollection

import org.hibernate.QueryException; //导入依赖的package包/类
/**
 * Locate the collection persister by the collection role, requiring that
 * such a persister exist.
 *
 * @param role The collection role name.
 *
 * @return The defined CollectionPersister for this collection role.
 *
 * @throws QueryException Indicates that the collection persister could not be found.
 */
public QueryableCollection requireQueryableCollection(String role) throws QueryException {
	try {
		QueryableCollection queryableCollection = (QueryableCollection) sfi.getCollectionPersister( role );
		if ( queryableCollection != null ) {
			collectionPropertyMappingByRole.put( role, new CollectionPropertyMapping( queryableCollection ) );
		}
		return queryableCollection;
	}
	catch ( ClassCastException cce ) {
		throw new QueryException( "collection role is not queryable: " + role );
	}
	catch ( Exception e ) {
		throw new QueryException( "collection role not found: " + role );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:SessionFactoryHelper.java

示例14: getNamedParameterLocations

import org.hibernate.QueryException; //导入依赖的package包/类
/**
 * Returns the locations of all occurrences of the named parameter.
 */
public int[] getNamedParameterLocations(String name) throws QueryException {
	Object o = namedParameters.get( name );
	if ( o == null ) {
		throw new QueryException(
				QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name,
				queryTranslatorImpl.getQueryString()
		);
	}
	if ( o instanceof Integer ) {
		return new int[] {(Integer) o};
	}
	else {
		return ArrayHelper.toIntArray( (ArrayList) o );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:HqlSqlWalker.java

示例15: validateTypes

import org.hibernate.QueryException; //导入依赖的package包/类
public void validateTypes(SelectClause selectClause) throws QueryException {
	Type[] selectTypes = selectClause.getQueryReturnTypes();
	if ( selectTypes.length + selectClause.getTotalParameterCount() != types.length ) {
		throw new QueryException( "number of select types did not match those for insert" );
	}

	int parameterCount = 0; 
	for ( int i = 0; i < types.length; i++ ) {
		if( selectClause.getParameterPositions().contains(i) ) {
			parameterCount++;
		}
		else if ( !areCompatible( types[i], selectTypes[i - parameterCount] ) ) {
			throw new QueryException(
			        "insertion type [" + types[i] + "] and selection type [" +
			        selectTypes[i - parameterCount] + "] at position " + i + " are not compatible"
			);
		}
	}

	// otherwise, everything ok.
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:IntoClause.java


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