public static JPQLException aliasResolutionException(String query, int line, int column, String theAlias) { Object[] args = { query, line, column, theAlias }; String message = ExceptionMessageGenerator.buildMessage(JPQLException.class, aliasResolutionException, args); JPQLException exception = new JPQLException(message); exception.setErrorCode(aliasResolutionException); return exception; }
/** * PUBLIC * Print the stack trace for each error generated by the * parser. This method is intended to assist in debugging * problems in EJBQL */ public void printFullStackTrace() { if (hasInternalExceptions()) { Iterator exceptions = getInternalExceptions().iterator(); while (exceptions.hasNext()) { Throwable error = (Throwable)exceptions.next(); error.printStackTrace(); } } } }
if (type == null) { throw JPQLException.unknownAttribute( context.getQueryInfo(), right.getLine(), right.getColumn(), name, typeHelper.getTypeName(left.getType())); enumConstant = typeHelper.resolveEnumConstant(type, name); if (enumConstant == null) { throw JPQLException.invalidEnumLiteral(context.getQueryInfo(), right.getLine(), right.getColumn(), typeName, name); throw JPQLException.aliasResolutionException( context.getQueryInfo(), leftMost.getLine(), leftMost.getColumn(), leftMost.getAsString());
public Object getTypeForMapKey(ParseTreeContext context){ String name = getCanonicalVariableName(); if (context.isRangeVariable(name)) { throw JPQLException.variableCannotHaveMapKey(context.getQueryInfo(), getLine(), getColumn(), name); } else { DotNode path = (DotNode)context.pathForVariable(name); if (path == null) { throw JPQLException.aliasResolutionException( context.getQueryInfo(), getLine(), getColumn(), name); } else { return path.getTypeForMapKey(context); } } }
/** * INTERNAL * Answer the class associated with the provided schema name */ public Class classForSchemaName(String schemaName, GenerationContext context) { ClassDescriptor descriptor = context.getSession().getDescriptorForAlias(schemaName); if (descriptor == null) { throw JPQLException.entityTypeNotFound(getQueryInfo(), schemaName); } Class theClass = descriptor.getJavaClass(); if (theClass == null) { throw JPQLException.resolutionClassNotFoundException(getQueryInfo(), schemaName); } return theClass; }
/** * INTERNAL * Generate an exception which encapsulates all the exceptions generated * by this parser. Special case where the first exception is an * JPQLException. */ protected JPQLException generateException() { //Handle exceptions we expect (such as expressionSotSupported) Exception firstException = (Exception)getErrors().get(0); if (firstException instanceof JPQLException) { return (JPQLException)firstException; } //Handle general exceptions, such as NPE JPQLException exception = JPQLException.generalParsingException(getQueryInfo()); exception.setInternalExceptions(getErrors()); return exception; }
/** * resolveClass: Answer the class which corresponds to my variableName. This is the class for * an alias, where the variableName is registered to an alias. */ public Class resolveClass(GenerationContext context) { String alias = abstractSchemaName; ClassDescriptor descriptor = context.getSession().getDescriptorForAlias(alias); if (descriptor == null) { throw JPQLException.entityTypeNotFound2( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), alias); } Class theClass = descriptor.getJavaClass(); if (theClass == null) { throw JPQLException.resolutionClassNotFoundException2( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), alias); } return theClass; } }
/** * INTERNAL * Validate node and calculate its type. */ public void validate(ParseTreeContext context) { TypeHelper typeHelper = context.getTypeHelper(); if (orderNode == null){ if (orderByItem instanceof Node){ orderNode = (Node)orderByItem; } else { orderNode = context.pathForVariable((String)orderByItem); if (orderNode == null){ throw JPQLException.nonExistantOrderByAlias( context.getQueryInfo(), getLine(), getColumn(), (String)orderByItem); } } } if (orderNode != null) { orderNode.validate(context); Object type = orderNode.getType(); setType(type); if (!typeHelper.isOrderableType(type)) { throw JPQLException.expectedOrderableOrderByItem( context.getQueryInfo(), orderNode.getLine(), orderNode.getColumn(), orderNode.getAsString(), typeHelper.getTypeName(type)); } } }
/** * resolveClass: Answer the class which corresponds to my variableName. This is the class for * an alias, where the variableName is registered to an alias. */ public Class resolveClass(GenerationContext generationContext) { Class clazz = null; String name = getCanonicalVariableName(); ParseTreeContext context = generationContext.getParseTreeContext(); if (context.isRangeVariable(name)) { String schema = context.schemaForVariable(name); clazz = context.classForSchemaName(schema, generationContext); } else { DotNode path = (DotNode)context.pathForVariable(name); if (path == null) { throw JPQLException.aliasResolutionException( context.getQueryInfo(), getLine(), getColumn(), name); } else { clazz = path.resolveClass(generationContext); } } return clazz; }
/** * INTERNAL * Add an internal Exception to the collection of * internal Exceptions */ public Object addInternalException(Object theException) { getInternalExceptions().add(theException); return theException; }
/** * INTERNAL * Add the exception to the list of errors. */ public void addError(Exception e) { if (e instanceof RecognitionException) { e = handleRecognitionException((RecognitionException)e); } else if (!(e instanceof JPQLException)) { e = JPQLException.generalParsingException(getQueryInfo(), e); } errors.add(e); }
public void validate(ParseTreeContext context) { TypeHelper typeHelper = context.getTypeHelper(); left.validate(context); if (!left.isVariableNode()){ throw JPQLException.indexOnlyAllowedOnVariable(context.getQueryInfo(), getLine(), getColumn(), left.getAsString()); } setType(typeHelper.getIntType()); } }
/** * Check the specifid constructor class and return its class instance. * @exception JPQLException if the specified constructor class could not * be found. */ private Class getConstructorClass(ParseTreeContext context) { Object type = getType(); if (type == null) { throw JPQLException.constructorClassNotFound( context.getQueryInfo(), getLine(), getColumn(), className); } return (Class)type; }
/** * INTERNAL * Validate node and calculate its type. */ public void validate(ParseTreeContext context) { super.validate(context); TypeHelper typeHelper = context.getTypeHelper(); Object type = typeHelper.resolveSchema(abstractSchemaName); if (type == null) { throw JPQLException.entityTypeNotFound2( context.getQueryInfo(), getLine(), getColumn(), abstractSchemaName); } setType(type); } }
private JPQLException buildUnexpectedException(CharSequence jpqlQuery, Exception exception) { String errorMessage = resourceBundle().getString(HermesParser_UnexpectedException_ErrorMessage); errorMessage = MessageFormat.format(errorMessage, jpqlQuery); return new JPQLException(errorMessage, exception); }
throw JPQLException.unknownAttribute( context.getQueryInfo(), right.getLine(), right.getColumn(), name, typeHelper.getTypeName(left.getType())); enumConstant = typeHelper.resolveEnumConstant(type, name); if (enumConstant == null) { throw JPQLException.invalidEnumLiteral(context.getQueryInfo(), right.getLine(), right.getColumn(), typeName, name); throw JPQLException.aliasResolutionException( context.getQueryInfo(), leftMost.getLine(), leftMost.getColumn(), leftMost.getAsString());
public Object getTypeForMapKey(ParseTreeContext context){ String name = getCanonicalVariableName(); if (context.isRangeVariable(name)) { throw JPQLException.variableCannotHaveMapKey(context.getQueryInfo(), getLine(), getColumn(), name); } else { DotNode path = (DotNode)context.pathForVariable(name); if (path == null) { throw JPQLException.aliasResolutionException( context.getQueryInfo(), getLine(), getColumn(), name); } else { return path.getTypeForMapKey(context); } } }
/** * INTERNAL * Answer the class associated with the provided schema name */ public Class classForSchemaName(String schemaName, GenerationContext context) { ClassDescriptor descriptor = context.getSession().getDescriptorForAlias(schemaName); if (descriptor == null) { throw JPQLException.entityTypeNotFound(getQueryInfo(), schemaName); } Class theClass = descriptor.getJavaClass(); if (theClass == null) { throw JPQLException.resolutionClassNotFoundException(getQueryInfo(), schemaName); } return theClass; }
/** * INTERNAL * Generate an exception which encapsulates all the exceptions generated * by this parser. Special case where the first exception is an * JPQLException. */ protected JPQLException generateException() { //Handle exceptions we expect (such as expressionSotSupported) Exception firstException = (Exception)getErrors().get(0); if (firstException instanceof JPQLException) { return (JPQLException)firstException; } //Handle general exceptions, such as NPE JPQLException exception = JPQLException.generalParsingException(getQueryInfo()); exception.setInternalExceptions(getErrors()); return exception; }
/** * resolveClass: Answer the class which corresponds to my variableName. This is the class for * an alias, where the variableName is registered to an alias. */ public Class resolveClass(GenerationContext context) { String alias = abstractSchemaName; ClassDescriptor descriptor = context.getSession().getDescriptorForAlias(alias); if (descriptor == null) { throw JPQLException.entityTypeNotFound2( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), alias); } Class theClass = descriptor.getJavaClass(); if (theClass == null) { throw JPQLException.resolutionClassNotFoundException2( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), alias); } return theClass; } }