1 21 package oracle.toplink.essentials.exceptions; 23 24 import oracle.toplink.essentials.queryframework.*; 25 import oracle.toplink.essentials.internal.queryframework.*; 26 import oracle.toplink.essentials.expressions.*; 27 import oracle.toplink.essentials.mappings.*; 28 import oracle.toplink.essentials.internal.helper.*; 29 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 30 import oracle.toplink.essentials.sessions.Record; 31 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 32 import oracle.toplink.essentials.descriptors.ClassDescriptor; 33 34 37 public class QueryException extends ValidationException { 38 protected transient DatabaseQuery query; 39 protected transient AbstractRecord queryArguments; 40 public final static int ADDITIONAL_SIZE_QUERY_NOT_SPECIFIED = 6001; 41 public final static int AGGREGATE_OBJECT_CANNOT_BE_DELETED = 6002; 42 public final static int ARGUMENT_SIZE_MISMATCH_IN_QUERY_AND_QUERY_DEFINITION = 6003; 43 public final static int BACKUP_CLONE_IS_ORIGINAL_FROM_PARENT = 6004; 44 public final static int BACKUP_CLONE_IS_ORIGINAL_FROM_SELF = 6005; 45 public final static int BATCH_READING_NOT_SUPPORTED = 6006; 46 public final static int DESCRIPTOR_IS_MISSING = 6007; 47 public final static int DESCRIPTOR_IS_MISSING_FOR_NAMED_QUERY = 6008; 48 public final static int INCORRECT_SIZE_QUERY_FOR_CURSOR_STREAM = 6013; 49 public final static int INVALID_QUERY = 6014; 50 public final static int INVALID_QUERY_KEY_IN_EXPRESSION = 6015; 51 public final static int INVALID_QUERY_ON_SERVER_SESSION = 6016; 52 public final static int NO_CONCRETE_CLASS_INDICATED = 6020; 53 public final static int NO_CURSOR_SUPPORT = 6021; 54 public final static int OBJECT_TO_INSERT_IS_EMPTY = 6023; 55 public final static int OBJECT_TO_MODIFY_NOT_SPECIFIED = 6024; 56 public final static int QUERY_NOT_DEFINED = 6026; 57 public final static int QUERY_SENT_TO_INACTIVE_UNIT_OF_WORK = 6027; 58 public final static int READ_BEYOND_QUERY = 6028; 59 public final static int REFERENCE_CLASS_MISSING = 6029; 60 public final static int REFRESH_NOT_POSSIBLE_WITHOUT_CACHE = 6030; 61 public final static int SIZE_ONLY_SUPPORTED_ON_EXPRESSION_QUERIES = 6031; 62 public final static int SQL_STATEMENT_NOT_SET_PROPERLY = 6032; 63 public final static int INVALID_QUERY_ITEM = 6034; 64 public final static int SELECTION_OBJECT_CANNOT_BE_NULL = 6041; 65 public final static int UNNAMED_QUERY_ON_SESSION_BROKER = 6042; 66 public final static int REPORT_RESULT_WITHOUT_PKS = 6043; 67 public final static int NULL_PRIMARY_KEY_IN_BUILDING_OBJECT = 6044; 68 public final static int NO_DESCRIPTOR_FOR_SUBCLASS = 6045; 69 public final static int CANNOT_DELETE_READ_ONLY_OBJECT = 6046; 70 public final static int INVALID_OPERATOR = 6047; 71 public final static int ILLEGAL_USE_OF_GETFIELD = 6048; 72 public final static int ILLEGAL_USE_OF_GETTABLE = 6049; 73 public final static int REPORT_QUERY_RESULT_SIZE_MISMATCH = 6050; 74 public final static int CANNOT_CACHE_PARTIAL_OBJECT = 6051; 75 public final static int OUTER_JOIN_ONLY_VALID_FOR_ONE_TO_ONE = 6052; 76 public final static int CANNOT_ADD_TO_CONTAINER = 6054; 77 public static final int METHOD_INVOCATION_FAILED = 6055; 78 public static final int CANNOT_CREATE_CLONE = 6056; 79 public static final int METHOD_NOT_VALID = 6057; 80 public static final int METHOD_DOES_NOT_EXIST_IN_CONTAINER_CLASS = 6058; 81 public static final int COULD_NOT_INSTANTIATE_CONTAINER_CLASS = 6059; 82 public static final int MAP_KEY_NOT_COMPARABLE = 6060; 83 public static final int CANNOT_ACCESS_METHOD_ON_OBJECT = 6061; 84 public static final int CALLED_METHOD_THREW_EXCEPTION = 6062; 85 public final static int INVALID_OPERATION = 6063; 86 public final static int CANNOT_REMOVE_FROM_CONTAINER = 6064; 87 public final static int CANNOT_ADD_ELEMENT = 6065; 88 public static final int BACKUP_CLONE_DELETED = 6066; 89 public final static int CANNOT_ACCESS_FIELD_ON_OBJECT = 6067; 90 public final static int CANNOT_COMPARE_TABLES_IN_EXPRESSION = 6068; 91 public final static int INVALID_TABLE_FOR_FIELD_IN_EXPRESSION = 6069; 92 public final static int INVALID_USE_OF_TO_MANY_QUERY_KEY_IN_EXPRESSION = 6070; 93 public final static int INVALID_USE_OF_ANY_OF_IN_EXPRESSION = 6071; 94 public final static int CANNOT_QUERY_ACROSS_VARIABLE_ONE_TO_ONE_MAPPING = 6072; 95 public final static int ILL_FORMED_EXPRESSION = 6073; 96 public final static int CANNOT_CONFORM_EXPRESSION = 6074; 97 public final static int INVALID_OPERATOR_FOR_OBJECT_EXPRESSION = 6075; 98 public final static int UNSUPPORTED_MAPPING_FOR_OBJECT_COMPARISON = 6076; 99 public final static int OBJECT_COMPARISON_CANNOT_BE_PARAMETERIZED = 6077; 100 public final static int INCORRECT_CLASS_FOR_OBJECT_COMPARISON = 6078; 101 public final static int CANNOT_COMPARE_TARGET_FOREIGN_KEYS_TO_NULL = 6079; 102 public final static int INVALID_DATABASE_CALL = 6080; 103 public final static int INVALID_DATABASE_ACCESSOR = 6081; 104 public final static int METHOD_DOES_NOT_EXIST_ON_EXPRESSION = 6082; 105 public final static int IN_CANNOT_BE_PARAMETERIZED = 6083; 106 public final static int REDIRECTION_CLASS_OR_METHOD_NOT_SET = 6084; 107 public final static int REDIRECTION_METHOD_NOT_DEFINED_CORRECTLY = 6085; 108 public final static int REDIRECTION_METHOD_ERROR = 6086; 109 public final static int EXAMPLE_AND_REFERENCE_OBJECT_CLASS_MISMATCH = 6087; 110 public final static int NO_ATTRIBUTES_FOR_REPORT_QUERY = 6088; 111 public final static int NO_EXPRESSION_BUILDER_CLASS_FOUND = 6089; 112 public final static int CANNOT_SET_REPORT_QUERY_TO_CHECK_CACHE_ONLY = 6090; 113 public final static int TYPE_MISMATCH_BETWEEN_ATTRIBUTE_AND_CONSTANT_ON_EXPRESSION = 6091; 114 public final static int MUST_INSTANTIATE_VALUEHOLDERS = 6092; 115 public final static int PARAMETER_NAME_MISMATCH = 6094; 116 public final static int CLONE_METHOD_REQUIRED = 6095; 117 public final static int CLONE_METHOD_INACCESSIBLE = 6096; 118 public final static int CLONE_METHOD_THORW_EXCEPTION = 6097; 119 public final static int UNEXPECTED_INVOCATION = 6098; 120 public final static int JOINING_ACROSS_INHERITANCE_WITH_MULTIPLE_TABLES = 6099; 121 public final static int MULTIPLE_ROWS_DETECTED_FROM_SINGLE_OBJECT_READ = 6100; 122 public final static int HISTORICAL_QUERIES_MUST_PRESERVE_GLOBAL_CACHE = 6101; 123 public final static int HISTORICAL_QUERIES_ONLY_SUPPORTED_ON_ORACLE = 6102; 124 public final static int INVALID_QUERY_ON_HISTORICAL_SESSION = 6103; 125 public final static int OBJECT_DOES_NOT_EXIST_IN_CACHE = 6104; 126 public final static int MUST_USE_CURSOR_STREAM_POLICY = 6105; 127 public final static int CLASS_PK_DOES_NOT_EXIST_IN_CACHE = 6106; 128 public final static int UPDATE_STATEMENTS_NOT_SPECIFIED = 6107; 129 public final static int INHERITANCE_WITH_MULTIPLE_TABLES_NOT_SUPPORTED = 6108; 130 public final static int QUERY_FETCHGROUP_NOT_DEFINED_IN_DESCRIPTOR = 6109; 131 public final static int CANNOT_CONFORM_UNFETCHED_ATTRIBUTE = 6110; 132 public final static int FETCH_GROUP_ATTRIBUTE_NOT_MAPPED = 6111; 133 public final static int FETCH_GROUP_NOT_SUPPORT_ON_REPORT_QUERY = 6112; 134 public final static int FETCH_GROUP_NOT_SUPPORT_ON_PARTIAL_ATTRIBUTE_READING = 6113; 135 public final static int FETCHGROUP_VALID_ONLY_IF_FETCHGROUP_MANAGER_IN_DESCRIPTOR = 6114; 136 public final static int ISOLATED_QUERY_EXECUTED_ON_SERVER_SESSION = 6115; 137 public final static int NO_CALL_OR_INTERACTION_SPECIFIED = 6116; 138 public final static int CANNOT_CACHE_CURSOR_RESULTS_ON_QUERY = 6117; 139 public final static int CANNOT_CACHE_ISOLATED_DATA_ON_QUERY = 6118; 140 public final static int MAPPING_FOR_EXPRESSION_DOES_NOT_SUPPORT_JOINING = 6119; 141 public final static int SPECIFIED_PARTIAL_ATTRIBUTE_DOES_NOT_EXIST = 6120; 142 public final static int INVALID_BUILDER_IN_QUERY = 6121; 143 public final static int INVALID_EXPRESSION = 6122; 144 public final static int INVALID_CONTAINER_CLASS = 6123; 145 public final static int INCORRECT_QUERY_FOUND = 6124; 146 public final static int CLEAR_QUERY_RESULTS_NOT_SUPPORTED = 6125; 147 public final static int CANNOT_CONFORM_AND_CACHE_QUERY_RESULTS = 6126; 148 public final static int REFLECTIVE_CALL_ON_TOPLINK_CLASS_FAILED = 6127; 149 public final static int BATCH_READING_NOT_SUPPORTED_WITH_CALL = 6128; 150 public final static int REFRESH_NOT_POSSIBLE_WITH_CHECK_CACHE_ONLY = 6129; 151 public final static int DISCRIMINATOR_COLUMN_NOT_SELECTED = 6130; 152 public final static int DELETE_ALL_QUERY_SPECIFIES_OBJECTS_BUT_NOT_SELECTION_CRITERIA = 6131; 153 public final static int NAMED_ARGUMENT_NOT_FOUND_IN_QUERY_PARAMETERS = 6132; 154 public final static int UPDATE_ALL_QUERY_ADD_UPDATE_FIELD_IS_NULL = 6133; 155 public final static int UPDATE_ALL_QUERY_ADD_UPDATE_DOES_NOT_DEFINE_FIELD = 6134; 156 public final static int UPDATE_ALL_QUERY_ADD_UPDATE_DEFINES_WRONG_FIELD = 6135; 157 public final static int POLYMORPHIC_REPORT_ITEM_NOT_SUPPORTED = 6136; 158 public final static int EXCEPTION_WHILE_USING_CONSTRUCTOR_EXPRESSION = 6137; 159 public final static int TEMP_TABLES_NOT_SUPPORTED = 6138; 160 public final static int MAPPING_FOR_FIELDRESULT_NOT_FOUND = 6139; 161 public final static int JOIN_EXPRESSIONS_NOT_APPLICABLE_ON_NON_OBJECT_REPORT_ITEM = 6140; 162 166 protected QueryException(String message) { 167 super(message); 168 } 169 170 174 protected QueryException(String message, DatabaseQuery query) { 175 super(message); 176 this.query = query; 177 } 178 179 public static QueryException additionalSizeQueryNotSpecified(DatabaseQuery query) { 180 Object [] args = { }; 181 182 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ADDITIONAL_SIZE_QUERY_NOT_SPECIFIED, args), query); 183 queryException.setErrorCode(ADDITIONAL_SIZE_QUERY_NOT_SPECIFIED); 184 return queryException; 185 } 186 187 public static QueryException aggregateObjectCannotBeDeletedOrWritten(ClassDescriptor descriptor, DatabaseQuery query) { 188 Object [] args = { descriptor.toString(), CR }; 189 190 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, AGGREGATE_OBJECT_CANNOT_BE_DELETED, args), query); 191 queryException.setErrorCode(AGGREGATE_OBJECT_CANNOT_BE_DELETED); 192 return queryException; 193 } 194 195 public static QueryException argumentSizeMismatchInQueryAndQueryDefinition(DatabaseQuery query) { 196 Object [] args = { }; 197 198 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ARGUMENT_SIZE_MISMATCH_IN_QUERY_AND_QUERY_DEFINITION, args), query); 199 queryException.setErrorCode(ARGUMENT_SIZE_MISMATCH_IN_QUERY_AND_QUERY_DEFINITION); 200 return queryException; 201 } 202 203 public static QueryException namedArgumentNotFoundInQueryParameters(String argumentName) { 204 Object [] args = {argumentName}; 205 206 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NAMED_ARGUMENT_NOT_FOUND_IN_QUERY_PARAMETERS, args)); 207 queryException.setErrorCode(NAMED_ARGUMENT_NOT_FOUND_IN_QUERY_PARAMETERS); 208 return queryException; 209 } 210 211 public static QueryException backupCloneIsDeleted(Object clone) { 212 Object [] args = { clone, clone.getClass(), new Integer (System.identityHashCode(clone)), CR }; 213 214 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, BACKUP_CLONE_DELETED, args)); 215 queryException.setErrorCode(BACKUP_CLONE_DELETED); 216 return queryException; 217 } 218 219 public static QueryException backupCloneIsOriginalFromParent(Object clone) { 220 Object [] args = { clone, clone.getClass(), new Integer (System.identityHashCode(clone)), CR }; 222 223 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, BACKUP_CLONE_IS_ORIGINAL_FROM_PARENT, args)); 224 queryException.setErrorCode(BACKUP_CLONE_IS_ORIGINAL_FROM_PARENT); 225 return queryException; 226 } 227 228 public static QueryException backupCloneIsOriginalFromSelf(Object clone) { 229 Object [] args = { clone, clone.getClass(), new Integer (System.identityHashCode(clone)), CR }; 230 231 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, BACKUP_CLONE_IS_ORIGINAL_FROM_SELF, args)); 232 queryException.setErrorCode(BACKUP_CLONE_IS_ORIGINAL_FROM_SELF); 233 return queryException; 234 } 235 236 public static QueryException batchReadingNotSupported(DatabaseMapping mapping, DatabaseQuery query) { 237 Object [] args = { mapping }; 238 239 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, BATCH_READING_NOT_SUPPORTED, args), query); 240 queryException.setErrorCode(BATCH_READING_NOT_SUPPORTED); 241 return queryException; 242 } 243 244 public static QueryException batchReadingNotSupported(DatabaseQuery query) { 245 Object [] args = { }; 246 247 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, BATCH_READING_NOT_SUPPORTED_WITH_CALL, args), query); 248 queryException.setErrorCode(BATCH_READING_NOT_SUPPORTED_WITH_CALL); 249 return queryException; 250 } 251 252 public static QueryException calledMethodThrewException(java.lang.reflect.Method aMethod, Object object, Exception ex) { 253 Object [] args = { aMethod, object, object.getClass() }; 254 255 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CALLED_METHOD_THREW_EXCEPTION, args)); 256 queryException.setErrorCode(CALLED_METHOD_THREW_EXCEPTION); 257 queryException.setInternalException(ex); 258 return queryException; 259 } 260 261 public static ValidationException cannotAccessFieldOnObject(java.lang.reflect.Field aField, Object anObject) { 262 Object [] args = { aField, anObject, anObject.getClass() }; 263 264 ValidationException validationException = new ValidationException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_ACCESS_FIELD_ON_OBJECT, args)); 265 validationException.setErrorCode(CANNOT_ACCESS_FIELD_ON_OBJECT); 266 return validationException; 267 } 268 269 public static ValidationException cannotAccessMethodOnObject(java.lang.reflect.Method aMethod, Object anObject) { 270 Object [] args = { aMethod, anObject, anObject.getClass() }; 271 272 ValidationException validationException = new ValidationException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_ACCESS_METHOD_ON_OBJECT, args)); 273 validationException.setErrorCode(CANNOT_ACCESS_METHOD_ON_OBJECT); 274 return validationException; 275 } 276 277 public static QueryException cannotAddElement(Object anObject, Object aContainer, Exception ex) { 278 Object [] args = { anObject, anObject.getClass(), aContainer.getClass() }; 279 280 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_ADD_ELEMENT, args)); 281 queryException.setErrorCode(CANNOT_ADD_ELEMENT); 282 queryException.setInternalException(ex); 283 return queryException; 284 } 285 286 public static QueryException cannotAddToContainer(Object anObject, Object aContainer, ContainerPolicy policy) { 287 Object [] args = { anObject, anObject.getClass(), aContainer.getClass(), policy }; 288 289 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_ADD_TO_CONTAINER, args)); 290 queryException.setErrorCode(CANNOT_ADD_TO_CONTAINER); 291 return queryException; 292 } 293 294 public static QueryException cannotCacheCursorResultsOnQuery(DatabaseQuery query) { 295 Object [] args = { }; 296 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CACHE_CURSOR_RESULTS_ON_QUERY, args)); 297 queryException.setQuery(query); 298 queryException.setErrorCode(CANNOT_CACHE_CURSOR_RESULTS_ON_QUERY); 299 return queryException; 300 } 301 302 public static QueryException cannotCacheIsolatedDataOnQuery(DatabaseQuery query) { 303 Object [] args = { }; 304 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CACHE_ISOLATED_DATA_ON_QUERY, args)); 305 queryException.setQuery(query); 306 queryException.setErrorCode(CANNOT_CACHE_ISOLATED_DATA_ON_QUERY); 307 return queryException; 308 } 309 310 public static QueryException cannotCachePartialObjects(DatabaseQuery query) { 311 Object [] args = { }; 312 313 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CACHE_PARTIAL_OBJECT, args)); 314 queryException.setQuery(query); 315 queryException.setErrorCode(CANNOT_CACHE_PARTIAL_OBJECT); 316 return queryException; 317 } 318 319 public static QueryException cannotCompareTablesInExpression(Object data) { 320 Object [] args = { data }; 321 322 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_COMPARE_TABLES_IN_EXPRESSION, args)); 323 queryException.setErrorCode(CANNOT_COMPARE_TABLES_IN_EXPRESSION); 324 return queryException; 325 } 326 327 public static QueryException cannotCompareTargetForeignKeysToNull(Expression expression, Object value, DatabaseMapping mapping) { 328 Object [] args = { expression, mapping, value, CR }; 329 330 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_COMPARE_TARGET_FOREIGN_KEYS_TO_NULL, args)); 331 queryException.setErrorCode(CANNOT_COMPARE_TARGET_FOREIGN_KEYS_TO_NULL); 332 return queryException; 333 } 334 335 public static QueryException cannotConformAndCacheQueryResults(ReadQuery query) { 336 Object [] args = { }; 337 338 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CONFORM_AND_CACHE_QUERY_RESULTS, args), query); 339 queryException.setErrorCode(CANNOT_CONFORM_AND_CACHE_QUERY_RESULTS); 340 return queryException; 341 } 342 343 public static QueryException cannotConformExpression() { 344 Object [] args = { }; 345 346 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CONFORM_EXPRESSION, args)); 347 queryException.setErrorCode(CANNOT_CONFORM_EXPRESSION); 348 return queryException; 349 } 350 351 public static QueryException cannotCreateClone(ContainerPolicy policy, Object anObject) { 352 Object [] args = { anObject, anObject.getClass(), policy }; 353 354 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CREATE_CLONE, args)); 355 queryException.setErrorCode(CANNOT_CREATE_CLONE); 356 return queryException; 357 } 358 359 public static QueryException cannotDeleteReadOnlyObject(Object anObject) { 360 Object [] args = { anObject.getClass().toString() }; 361 362 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_DELETE_READ_ONLY_OBJECT, args)); 363 queryException.setErrorCode(CANNOT_DELETE_READ_ONLY_OBJECT); 364 return queryException; 365 } 366 367 public static QueryException cannotQueryAcrossAVariableOneToOneMapping(DatabaseMapping mapping, ClassDescriptor descriptor) { 368 Object [] args = { descriptor.toString(), mapping.toString(), CR }; 369 370 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_QUERY_ACROSS_VARIABLE_ONE_TO_ONE_MAPPING, args)); 371 queryException.setErrorCode(CANNOT_QUERY_ACROSS_VARIABLE_ONE_TO_ONE_MAPPING); 372 return queryException; 373 } 374 375 public static QueryException cannotRemoveFromContainer(Object anObject, Object aContainer, ContainerPolicy policy) { 376 Object [] args = { anObject, anObject.getClass(), aContainer.getClass(), policy }; 377 378 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_REMOVE_FROM_CONTAINER, args)); 379 queryException.setErrorCode(CANNOT_REMOVE_FROM_CONTAINER); 380 return queryException; 381 } 382 383 public static QueryException cannotSetShouldCheckCacheOnlyOnReportQuery() { 384 Object [] args = { }; 385 386 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_SET_REPORT_QUERY_TO_CHECK_CACHE_ONLY, args)); 387 queryException.setErrorCode(CANNOT_SET_REPORT_QUERY_TO_CHECK_CACHE_ONLY); 388 return queryException; 389 } 390 391 public static QueryException couldNotInstantiateContainerClass(Class aClass, Exception exception) { 392 Object [] args = { aClass.toString() }; 393 394 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, COULD_NOT_INSTANTIATE_CONTAINER_CLASS, args)); 395 queryException.setErrorCode(COULD_NOT_INSTANTIATE_CONTAINER_CLASS); 396 queryException.setInternalException(exception); 397 return queryException; 398 } 399 400 public static QueryException descriptorIsMissing(Class referenceClass, DatabaseQuery query) { 401 Object [] args = { referenceClass }; 402 403 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, DESCRIPTOR_IS_MISSING, args), query); 404 queryException.setErrorCode(DESCRIPTOR_IS_MISSING); 405 return queryException; 406 } 407 408 public static QueryException descriptorIsMissingForNamedQuery(Class domainClass, String queryName) { 409 Object [] args = { domainClass.getName(), queryName }; 410 411 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, DESCRIPTOR_IS_MISSING_FOR_NAMED_QUERY, args)); 412 queryException.setErrorCode(DESCRIPTOR_IS_MISSING_FOR_NAMED_QUERY); 413 return queryException; 414 } 415 416 public static QueryException discriminatorColumnNotSelected(String expectedColumn, String sqlResultSetMapping){ 417 Object [] args = { expectedColumn, sqlResultSetMapping }; 418 419 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, DISCRIMINATOR_COLUMN_NOT_SELECTED, args)); 420 queryException.setErrorCode(DISCRIMINATOR_COLUMN_NOT_SELECTED); 421 return queryException; 422 } 423 427 public static QueryException exampleAndReferenceObjectClassMismatch(Class exampleObjectClass, Class referenceObjectClass, DatabaseQuery query) { 428 Object [] args = { exampleObjectClass, referenceObjectClass }; 429 430 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, EXAMPLE_AND_REFERENCE_OBJECT_CLASS_MISMATCH, args)); 431 queryException.setErrorCode(EXAMPLE_AND_REFERENCE_OBJECT_CLASS_MISMATCH); 432 queryException.setQuery(query); 433 return queryException; 434 } 435 436 439 public static QueryException exceptionWhileUsingConstructorExpression(Exception thrownException, DatabaseQuery query) { 440 Object [] args = { thrownException }; 441 442 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, EXCEPTION_WHILE_USING_CONSTRUCTOR_EXPRESSION, args)); 443 queryException.setErrorCode(EXCEPTION_WHILE_USING_CONSTRUCTOR_EXPRESSION); 444 queryException.setQuery(query); 445 return queryException; 446 } 447 448 453 public String getMessage() { 454 if (getQuery() == null) { 455 return super.getMessage(); 456 } else { 457 return super.getMessage() + cr() + getIndentationString() + ExceptionMessageGenerator.getHeader("QueryHeader") + getQuery().toString(); 458 } 459 } 460 461 465 public DatabaseQuery getQuery() { 466 return query; 467 } 468 469 473 public Record getQueryArgumentsRecord() { 474 return queryArguments; 475 } 476 477 public static QueryException illegalUseOfGetField(Object data) { 478 Object [] args = { data }; 479 480 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ILLEGAL_USE_OF_GETFIELD, args)); 481 queryException.setErrorCode(ILLEGAL_USE_OF_GETFIELD); 482 return queryException; 483 } 484 485 public static QueryException illegalUseOfGetTable(Object data) { 486 Object [] args = { data }; 487 488 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ILLEGAL_USE_OF_GETTABLE, args)); 489 queryException.setErrorCode(ILLEGAL_USE_OF_GETTABLE); 490 return queryException; 491 } 492 493 public static QueryException illFormedExpression(oracle.toplink.essentials.expressions.Expression queryKey) { 494 Object [] args = { queryKey }; 495 496 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ILL_FORMED_EXPRESSION, args)); 497 queryException.setErrorCode(ILL_FORMED_EXPRESSION); 498 return queryException; 499 } 500 501 public static QueryException inCannotBeParameterized(DatabaseQuery query) { 502 Object [] args = { }; 503 504 QueryException exception = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, IN_CANNOT_BE_PARAMETERIZED, args), query); 505 exception.setErrorCode(IN_CANNOT_BE_PARAMETERIZED); 506 return exception; 507 } 508 509 public static QueryException incorrectClassForObjectComparison(Expression expression, Object value, DatabaseMapping mapping) { 510 Object [] args = { expression, mapping, value, CR }; 511 512 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INCORRECT_CLASS_FOR_OBJECT_COMPARISON, args)); 513 queryException.setErrorCode(INCORRECT_CLASS_FOR_OBJECT_COMPARISON); 514 return queryException; 515 } 516 517 public static QueryException incorrectSizeQueryForCursorStream(DatabaseQuery query) { 518 Object [] args = { }; 519 520 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INCORRECT_SIZE_QUERY_FOR_CURSOR_STREAM, args), query); 521 queryException.setErrorCode(INCORRECT_SIZE_QUERY_FOR_CURSOR_STREAM); 522 return queryException; 523 } 524 525 public static QueryException incorrectQueryObjectFound(DatabaseQuery query, Class expectedQueryClass) { 526 Object [] args = { expectedQueryClass, query.getClass() }; 527 528 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INCORRECT_QUERY_FOUND, args), query); 529 queryException.setErrorCode(INCORRECT_QUERY_FOUND); 530 return queryException; 531 } 532 533 public static QueryException invalidContainerClass(Class containerGiven, Class containerRequired) { 534 Object [] args = { containerGiven, containerRequired }; 535 536 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_CONTAINER_CLASS, args)); 537 queryException.setErrorCode(INVALID_CONTAINER_CLASS); 538 return queryException; 539 } 540 541 public static QueryException invalidDatabaseAccessor(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor) { 542 Object [] args = { accessor }; 543 544 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_DATABASE_ACCESSOR, args)); 545 queryException.setErrorCode(INVALID_DATABASE_ACCESSOR); 546 return queryException; 547 } 548 549 public static QueryException invalidDatabaseCall(Call call) { 550 Object [] args = { call }; 551 552 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_DATABASE_CALL, args)); 553 queryException.setErrorCode(INVALID_DATABASE_CALL); 554 return queryException; 555 } 556 557 public static QueryException invalidExpressionForQueryItem(Expression expression, DatabaseQuery owner) { 558 Object [] args = { expression }; 559 560 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_QUERY_ITEM, args), owner); 561 queryException.setErrorCode(INVALID_QUERY_ITEM); 562 return queryException; 563 } 564 565 public static QueryException invalidOperation(String operation) { 566 Object [] args = { operation }; 567 568 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_OPERATION, args)); 569 queryException.setErrorCode(INVALID_OPERATION); 570 return queryException; 571 } 572 573 public static QueryException invalidOperator(Object data) { 574 Object [] args = { data }; 575 576 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_OPERATOR, args)); 577 queryException.setErrorCode(INVALID_OPERATOR); 578 return queryException; 579 } 580 581 public static QueryException invalidOperatorForObjectComparison(Expression expression) { 582 Object [] args = { expression, CR }; 583 584 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_OPERATOR_FOR_OBJECT_EXPRESSION, args)); 585 queryException.setErrorCode(INVALID_OPERATOR_FOR_OBJECT_EXPRESSION); 586 return queryException; 587 } 588 589 public static QueryException invalidQuery(DatabaseQuery query) { 590 Object [] args = { }; 591 592 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_QUERY, args), query); 593 queryException.setErrorCode(INVALID_QUERY); 594 return queryException; 595 } 596 597 public static QueryException invalidBuilderInQuery(DatabaseQuery query) { 598 Object [] args = { }; 599 600 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_BUILDER_IN_QUERY, args), query); 601 queryException.setErrorCode(INVALID_BUILDER_IN_QUERY); 602 return queryException; 603 } 604 605 public static QueryException invalidQueryKeyInExpression(Object data) { 606 Object [] args = { data }; 607 608 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_QUERY_KEY_IN_EXPRESSION, args)); 609 queryException.setErrorCode(INVALID_QUERY_KEY_IN_EXPRESSION); 610 return queryException; 611 } 612 613 public static QueryException invalidExpression(Object expression) { 614 Object [] args = { expression }; 615 616 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_EXPRESSION, args)); 617 queryException.setErrorCode(INVALID_EXPRESSION); 618 return queryException; 619 } 620 621 public static QueryException mappingForExpressionDoesNotSupportJoining(Object expression) { 622 Object [] args = { expression }; 623 624 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAPPING_FOR_EXPRESSION_DOES_NOT_SUPPORT_JOINING, args)); 625 queryException.setErrorCode(MAPPING_FOR_EXPRESSION_DOES_NOT_SUPPORT_JOINING); 626 return queryException; 627 } 628 629 public static QueryException mappingForFieldResultNotFound(String [] attributeNames, int currentString){ 630 String attributeName =""; 631 for(int i=0; i<attributeNames.length;i++){ 632 attributeName=attributeName+attributeNames[i]; 633 } 634 Object [] args = { attributeName, attributeNames[currentString] }; 635 636 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAPPING_FOR_FIELDRESULT_NOT_FOUND, args)); 637 queryException.setErrorCode(MAPPING_FOR_FIELDRESULT_NOT_FOUND); 638 return queryException; 639 } 640 641 public static QueryException invalidQueryOnHistoricalSession(DatabaseQuery query) { 642 Object [] args = { }; 643 644 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_QUERY_ON_HISTORICAL_SESSION, args), query); 645 queryException.setErrorCode(INVALID_QUERY_ON_HISTORICAL_SESSION); 646 return queryException; 647 } 648 649 public static QueryException invalidQueryOnServerSession(DatabaseQuery query) { 650 Object [] args = { }; 651 652 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_QUERY_ON_SERVER_SESSION, args), query); 653 queryException.setErrorCode(INVALID_QUERY_ON_SERVER_SESSION); 654 return queryException; 655 } 656 657 public static QueryException invalidTableForFieldInExpression(Object data) { 658 Object [] args = { data }; 659 660 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_TABLE_FOR_FIELD_IN_EXPRESSION, args)); 661 queryException.setErrorCode(INVALID_TABLE_FOR_FIELD_IN_EXPRESSION); 662 return queryException; 663 } 664 665 public static QueryException invalidUseOfAnyOfInExpression(Object data) { 666 Object [] args = { data }; 667 668 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_USE_OF_ANY_OF_IN_EXPRESSION, args)); 669 queryException.setErrorCode(INVALID_USE_OF_ANY_OF_IN_EXPRESSION); 670 return queryException; 671 } 672 673 public static QueryException joinExpressionsNotApplicableOnNonObjectReportItem(String expressionType, String itemName) { 674 Object [] args = { expressionType, itemName }; 675 676 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, JOIN_EXPRESSIONS_NOT_APPLICABLE_ON_NON_OBJECT_REPORT_ITEM, args)); 677 queryException.setErrorCode(JOIN_EXPRESSIONS_NOT_APPLICABLE_ON_NON_OBJECT_REPORT_ITEM); 678 return queryException; 679 } 680 681 public static QueryException joiningAcrossInheritanceClassWithMultipleTablesNotSupported(DatabaseQuery query, Class joinClass) { 682 Object [] args = { query, joinClass }; 683 684 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, JOINING_ACROSS_INHERITANCE_WITH_MULTIPLE_TABLES, args)); 685 queryException.setErrorCode(JOINING_ACROSS_INHERITANCE_WITH_MULTIPLE_TABLES); 686 return queryException; 687 } 688 689 public static QueryException invalidUseOfToManyQueryKeyInExpression(Object data) { 690 Object [] args = { data }; 691 692 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INVALID_USE_OF_TO_MANY_QUERY_KEY_IN_EXPRESSION, args)); 693 queryException.setErrorCode(INVALID_USE_OF_TO_MANY_QUERY_KEY_IN_EXPRESSION); 694 return queryException; 695 } 696 697 public static QueryException isolatedQueryExecutedOnServerSession() { 698 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, ISOLATED_QUERY_EXECUTED_ON_SERVER_SESSION, new Object [] { })); 699 queryException.setErrorCode(ISOLATED_QUERY_EXECUTED_ON_SERVER_SESSION); 700 return queryException; 701 } 702 703 public static ValidationException mapKeyNotComparable(Object anObject, Object aContainer) { 704 Object [] args = { anObject.toString(), anObject.getClass(), aContainer, aContainer.getClass() }; 705 706 ValidationException validationException = new ValidationException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAP_KEY_NOT_COMPARABLE, args)); 707 validationException.setErrorCode(MAP_KEY_NOT_COMPARABLE); 708 return validationException; 709 } 710 711 public static QueryException methodDoesNotExistInContainerClass(String methodName, Class aClass) { 712 Object [] args = { methodName, aClass }; 713 714 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, METHOD_DOES_NOT_EXIST_IN_CONTAINER_CLASS, args)); 715 queryException.setErrorCode(METHOD_DOES_NOT_EXIST_IN_CONTAINER_CLASS); 716 return queryException; 717 } 718 719 public static QueryException methodDoesNotExistOnExpression(String methodName, Class [] argTypes) { 720 Object [] args = { methodName, argTypes }; 721 722 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, METHOD_DOES_NOT_EXIST_ON_EXPRESSION, args)); 723 queryException.setErrorCode(METHOD_DOES_NOT_EXIST_ON_EXPRESSION); 724 return queryException; 725 } 726 727 public static QueryException methodInvocationFailed(java.lang.reflect.Method aMethod, Object anObject, Exception ex) { 728 Object [] args = { aMethod, anObject, anObject.getClass() }; 729 730 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, METHOD_INVOCATION_FAILED, args)); 731 queryException.setErrorCode(METHOD_INVOCATION_FAILED); 732 queryException.setInternalException(ex); 733 return queryException; 734 } 735 736 public static QueryException methodNotValid(Object aReceiver, String methodName) { 737 Object [] args = { methodName, aReceiver }; 738 739 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, METHOD_NOT_VALID, args)); 740 queryException.setErrorCode(METHOD_NOT_VALID); 741 return queryException; 742 } 743 744 public static QueryException mustInstantiateValueholders() { 745 Object [] args = { }; 746 747 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MUST_INSTANTIATE_VALUEHOLDERS, args)); 748 queryException.setErrorCode(MUST_INSTANTIATE_VALUEHOLDERS); 749 return queryException; 750 } 751 752 756 public static QueryException noAttributesForReportQuery(DatabaseQuery query) { 757 Object [] args = { }; 758 759 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NO_ATTRIBUTES_FOR_REPORT_QUERY, args)); 760 queryException.setErrorCode(NO_ATTRIBUTES_FOR_REPORT_QUERY); 761 queryException.setQuery(query); 762 return queryException; 763 } 764 765 public static QueryException noConcreteClassIndicated(AbstractRecord row, DatabaseQuery query) { 766 Object [] args = { row }; 767 768 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NO_CONCRETE_CLASS_INDICATED, args), query); 769 queryException.setErrorCode(NO_CONCRETE_CLASS_INDICATED); 770 return queryException; 771 } 772 773 public static QueryException noCallOrInteractionSpecified() { 774 Object [] args = { }; 775 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, QueryException.NO_CALL_OR_INTERACTION_SPECIFIED, args)); 776 queryException.setErrorCode(NO_CALL_OR_INTERACTION_SPECIFIED); 777 return queryException; 778 } 779 780 public static QueryException noCursorSupport(DatabaseQuery query) { 781 Object [] args = { }; 782 783 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NO_CURSOR_SUPPORT, args), query); 784 queryException.setErrorCode(NO_CURSOR_SUPPORT); 785 return queryException; 786 } 787 788 public static QueryException noDescriptorForClassFromInheritancePolicy(DatabaseQuery query, Class referenceClass) { 789 Object [] args = { String.valueOf(referenceClass) }; 790 791 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NO_DESCRIPTOR_FOR_SUBCLASS, args), query); 792 queryException.setErrorCode(NO_DESCRIPTOR_FOR_SUBCLASS); 793 return queryException; 794 } 795 796 public static QueryException noExpressionBuilderFound(Expression expression) { 797 Object [] args = { expression, CR }; 798 799 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NO_EXPRESSION_BUILDER_CLASS_FOUND, args)); 800 queryException.setErrorCode(NO_EXPRESSION_BUILDER_CLASS_FOUND); 801 return queryException; 802 } 803 804 public static QueryException nullPrimaryKeyInBuildingObject(DatabaseQuery query, AbstractRecord databaseRow) { 805 Object [] args = { databaseRow }; 806 807 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, NULL_PRIMARY_KEY_IN_BUILDING_OBJECT, args), query); 808 queryException.setErrorCode(NULL_PRIMARY_KEY_IN_BUILDING_OBJECT); 809 return queryException; 810 } 811 812 public static QueryException objectComparisonsCannotBeParameterized(Expression expression) { 813 Object [] args = { expression, CR }; 814 815 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, OBJECT_COMPARISON_CANNOT_BE_PARAMETERIZED, args)); 816 queryException.setErrorCode(OBJECT_COMPARISON_CANNOT_BE_PARAMETERIZED); 817 return queryException; 818 } 819 820 public static QueryException objectDoesNotExistInCache(Object object) { 821 Object [] args = { object }; 822 823 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, OBJECT_DOES_NOT_EXIST_IN_CACHE, args)); 824 queryException.setErrorCode(OBJECT_DOES_NOT_EXIST_IN_CACHE); 825 return queryException; 826 } 827 828 public static QueryException classPkDoesNotExistInCache(Class theClass, java.util.Vector primaryKey) { 829 Object [] args = { theClass, primaryKey }; 830 831 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CLASS_PK_DOES_NOT_EXIST_IN_CACHE, args)); 832 queryException.setErrorCode(CLASS_PK_DOES_NOT_EXIST_IN_CACHE); 833 return queryException; 834 } 835 836 public static QueryException clearQueryResultsNotSupported(ReadQuery query) { 837 Object [] args = { }; 838 839 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CLEAR_QUERY_RESULTS_NOT_SUPPORTED, args), query); 840 queryException.setErrorCode(CLEAR_QUERY_RESULTS_NOT_SUPPORTED); 841 return queryException; 842 } 843 844 public static QueryException objectToInsertIsEmpty(DatabaseTable table) { 845 Object [] args = { table }; 846 847 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, OBJECT_TO_INSERT_IS_EMPTY, args)); 848 queryException.setErrorCode(OBJECT_TO_INSERT_IS_EMPTY); 849 return queryException; 850 } 851 852 public static QueryException objectToModifyNotSpecified(DatabaseQuery query) { 853 Object [] args = { }; 854 855 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, OBJECT_TO_MODIFY_NOT_SPECIFIED, args), query); 856 queryException.setErrorCode(OBJECT_TO_MODIFY_NOT_SPECIFIED); 857 return queryException; 858 } 859 860 public static QueryException outerJoinIsOnlyValidForOneToOneMappings(DatabaseMapping mapping) { 861 Object [] args = { mapping.toString() }; 862 863 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, OUTER_JOIN_ONLY_VALID_FOR_ONE_TO_ONE, args)); 864 queryException.setErrorCode(OUTER_JOIN_ONLY_VALID_FOR_ONE_TO_ONE); 865 return queryException; 866 } 867 868 public static QueryException queryNotDefined() { 869 Object [] args = { "", "" }; 870 return queryNotDefined(args); 871 } 872 873 public static QueryException queryNotDefined(String queryName) { 874 Object [] args = { queryName, "" }; 875 return queryNotDefined(args); 876 } 877 878 public static QueryException queryNotDefined(String queryName, Class domainClass) { 879 Object [] args = { queryName, domainClass }; 880 return queryNotDefined(args); 881 } 882 883 private static QueryException queryNotDefined(Object [] args) { 884 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, QUERY_NOT_DEFINED, args)); 885 queryException.setErrorCode(QUERY_NOT_DEFINED); 886 return queryException; 887 } 888 889 public static QueryException querySentToInactiveUnitOfWork(DatabaseQuery query) { 890 Object [] args = { }; 891 892 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, QUERY_SENT_TO_INACTIVE_UNIT_OF_WORK, args), query); 893 queryException.setErrorCode(QUERY_SENT_TO_INACTIVE_UNIT_OF_WORK); 894 return queryException; 895 } 896 897 public static QueryException readBeyondStream(DatabaseQuery query) { 898 Object [] args = { }; 899 900 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, READ_BEYOND_QUERY, args), query); 901 queryException.setErrorCode(READ_BEYOND_QUERY); 902 return queryException; 903 } 904 905 public static QueryException redirectionClassOrMethodNotSet(DatabaseQuery query) { 906 Object [] args = { }; 907 908 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REDIRECTION_CLASS_OR_METHOD_NOT_SET, args), query); 909 queryException.setErrorCode(REDIRECTION_CLASS_OR_METHOD_NOT_SET); 910 return queryException; 911 } 912 913 public static QueryException redirectionMethodError(Exception exception, DatabaseQuery query) { 914 Object [] args = { }; 915 916 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REDIRECTION_METHOD_ERROR, args), query); 917 queryException.setInternalException(exception); 918 queryException.setErrorCode(REDIRECTION_METHOD_ERROR); 919 return queryException; 920 } 921 922 public static QueryException redirectionMethodNotDefinedCorrectly(Class methodClass, String methodName, Exception exception, DatabaseQuery query) { 923 Object [] args = { methodClass, methodName, CR }; 924 925 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REDIRECTION_METHOD_NOT_DEFINED_CORRECTLY, args), query); 926 queryException.setInternalException(exception); 927 queryException.setErrorCode(REDIRECTION_METHOD_NOT_DEFINED_CORRECTLY); 928 return queryException; 929 } 930 931 public static QueryException referenceClassMissing(DatabaseQuery query) { 932 Object [] args = { }; 933 934 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REFERENCE_CLASS_MISSING, args), query); 935 queryException.setErrorCode(REFERENCE_CLASS_MISSING); 936 return queryException; 937 } 938 939 public static QueryException refreshNotPossibleWithoutCache(DatabaseQuery query) { 940 Object [] args = { }; 941 942 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REFRESH_NOT_POSSIBLE_WITHOUT_CACHE, args), query); 943 queryException.setErrorCode(REFRESH_NOT_POSSIBLE_WITHOUT_CACHE); 944 return queryException; 945 } 946 947 public static QueryException reportQueryResultSizeMismatch(int expected, int retrieved) { 948 Object [] args = { new Integer (expected), new Integer (retrieved) }; 949 950 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REPORT_QUERY_RESULT_SIZE_MISMATCH, args)); 951 queryException.setErrorCode(REPORT_QUERY_RESULT_SIZE_MISMATCH); 952 return queryException; 953 } 954 955 public static QueryException reportQueryResultWithoutPKs(ReportQueryResult result) { 956 Object [] args = { result, CR }; 957 958 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REPORT_RESULT_WITHOUT_PKS, args), null); 959 queryException.setErrorCode(REPORT_RESULT_WITHOUT_PKS); 960 return queryException; 961 } 962 963 public static QueryException parameterNameMismatch(String badParameterName) { 964 Object [] args = { badParameterName }; 965 966 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, PARAMETER_NAME_MISMATCH, args), null); 967 queryException.setErrorCode(PARAMETER_NAME_MISMATCH); 968 return queryException; 969 } 970 971 public static QueryException polymorphicReportItemWithMultipletableNotSupported(String itemName, Expression expression, DatabaseQuery owner) { 972 Object [] args = { itemName, expression }; 973 974 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, POLYMORPHIC_REPORT_ITEM_NOT_SUPPORTED, args), owner); 975 queryException.setErrorCode(POLYMORPHIC_REPORT_ITEM_NOT_SUPPORTED); 976 return queryException; 977 } 978 979 public static QueryException selectionObjectCannotBeNull(DatabaseQuery query) { 980 Object [] args = { }; 981 982 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, SELECTION_OBJECT_CANNOT_BE_NULL, args), query); 983 queryException.setErrorCode(SELECTION_OBJECT_CANNOT_BE_NULL); 984 return queryException; 985 } 986 987 991 public void setQuery(DatabaseQuery query) { 992 this.query = query; 993 } 994 995 999 public void setQueryArguments(AbstractRecord queryArguments) { 1000 this.queryArguments = queryArguments; 1001 } 1002 1003 public static QueryException sizeOnlySupportedOnExpressionQueries(DatabaseQuery query) { 1004 Object [] args = { }; 1005 1006 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, SIZE_ONLY_SUPPORTED_ON_EXPRESSION_QUERIES, args), query); 1007 queryException.setErrorCode(SIZE_ONLY_SUPPORTED_ON_EXPRESSION_QUERIES); 1008 return queryException; 1009 } 1010 1011 public static QueryException specifiedPartialAttributeDoesNotExist(DatabaseQuery query, String attributeName, String targetClassName) { 1012 Object [] args = { attributeName, targetClassName }; 1013 1014 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, SPECIFIED_PARTIAL_ATTRIBUTE_DOES_NOT_EXIST, args), query); 1015 queryException.setErrorCode(SPECIFIED_PARTIAL_ATTRIBUTE_DOES_NOT_EXIST); 1016 return queryException; 1017 } 1018 1019 public static QueryException sqlStatementNotSetProperly(DatabaseQuery query) { 1020 Object [] args = { }; 1021 1022 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, SQL_STATEMENT_NOT_SET_PROPERLY, args), query); 1023 queryException.setErrorCode(SQL_STATEMENT_NOT_SET_PROPERLY); 1024 return queryException; 1025 } 1026 1027 public static QueryException typeMismatchBetweenAttributeAndConstantOnExpression(Class constantClass, Class attributeClass) { 1028 Object [] args = { constantClass, attributeClass }; 1029 1030 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, TYPE_MISMATCH_BETWEEN_ATTRIBUTE_AND_CONSTANT_ON_EXPRESSION, args)); 1031 queryException.setErrorCode(TYPE_MISMATCH_BETWEEN_ATTRIBUTE_AND_CONSTANT_ON_EXPRESSION); 1032 return queryException; 1033 } 1034 1035 public static QueryException unnamedQueryOnSessionBroker(DatabaseQuery query) { 1036 Object [] args = { }; 1037 1038 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UNNAMED_QUERY_ON_SESSION_BROKER, args), query); 1039 queryException.setErrorCode(UNNAMED_QUERY_ON_SESSION_BROKER); 1040 return queryException; 1041 } 1042 1043 public static QueryException unsupportedMappingForObjectComparison(DatabaseMapping mapping, Expression expression) { 1044 Object [] args = { mapping, expression, CR }; 1045 1046 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UNSUPPORTED_MAPPING_FOR_OBJECT_COMPARISON, args)); 1047 queryException.setErrorCode(UNSUPPORTED_MAPPING_FOR_OBJECT_COMPARISON); 1048 return queryException; 1049 } 1050 1051 public static QueryException updateStatementsNotSpecified() { 1052 Object [] args = { }; 1053 1054 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UPDATE_STATEMENTS_NOT_SPECIFIED, args)); 1055 queryException.setErrorCode(UPDATE_STATEMENTS_NOT_SPECIFIED); 1056 return queryException; 1057 } 1058 1059 public static QueryException inheritanceWithMultipleTablesNotSupported() { 1060 Object [] args = { }; 1061 1062 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, INHERITANCE_WITH_MULTIPLE_TABLES_NOT_SUPPORTED, args)); 1063 queryException.setErrorCode(INHERITANCE_WITH_MULTIPLE_TABLES_NOT_SUPPORTED); 1064 return queryException; 1065 } 1066 1067 public static QueryException cloneMethodRequired() { 1068 Object [] args = { }; 1069 1070 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CLONE_METHOD_REQUIRED, args)); 1071 queryException.setErrorCode(CLONE_METHOD_REQUIRED); 1072 return queryException; 1073 } 1074 1075 public static QueryException cloneMethodInaccessible() { 1076 Object [] args = { }; 1077 1078 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CLONE_METHOD_INACCESSIBLE, args)); 1079 queryException.setErrorCode(CLONE_METHOD_INACCESSIBLE); 1080 return queryException; 1081 } 1082 1083 public static QueryException cloneMethodThrowException(Throwable exception) { 1084 Object [] args = { exception }; 1085 1086 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CLONE_METHOD_THORW_EXCEPTION, args)); 1087 queryException.setErrorCode(CLONE_METHOD_THORW_EXCEPTION); 1088 return queryException; 1089 } 1090 1091 public static QueryException unexpectedInvocation(String message) { 1092 Object [] args = { message }; 1093 1094 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UNEXPECTED_INVOCATION, args)); 1095 queryException.setErrorCode(UNEXPECTED_INVOCATION); 1096 return queryException; 1097 } 1098 1099 public static QueryException multipleRowsDetectedFromReadObjectQuery() { 1100 Object [] args = { }; 1101 1102 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MULTIPLE_ROWS_DETECTED_FROM_SINGLE_OBJECT_READ, args)); 1103 queryException.setErrorCode(MULTIPLE_ROWS_DETECTED_FROM_SINGLE_OBJECT_READ); 1104 return queryException; 1105 } 1106 1107 public static QueryException historicalQueriesMustPreserveGlobalCache() { 1109 Object [] args = { }; 1110 1111 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, HISTORICAL_QUERIES_MUST_PRESERVE_GLOBAL_CACHE, args)); 1112 queryException.setErrorCode(HISTORICAL_QUERIES_MUST_PRESERVE_GLOBAL_CACHE); 1113 return queryException; 1114 } 1115 1116 public static QueryException historicalQueriesOnlySupportedOnOracle() { 1117 Object [] args = { }; 1118 1119 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, HISTORICAL_QUERIES_ONLY_SUPPORTED_ON_ORACLE, args)); 1120 queryException.setErrorCode(HISTORICAL_QUERIES_ONLY_SUPPORTED_ON_ORACLE); 1121 return queryException; 1122 } 1123 1124 public static QueryException mustUseCursorStreamPolicy() { 1125 Object [] args = { }; 1126 1127 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MUST_USE_CURSOR_STREAM_POLICY, args)); 1128 queryException.setErrorCode(MUST_USE_CURSOR_STREAM_POLICY); 1129 return queryException; 1130 } 1131 1132 public static QueryException fetchGroupNotDefinedInDescriptor(String fetchGroupName) { 1133 Object [] args = { fetchGroupName }; 1134 1135 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, QUERY_FETCHGROUP_NOT_DEFINED_IN_DESCRIPTOR, args)); 1136 queryException.setErrorCode(QUERY_FETCHGROUP_NOT_DEFINED_IN_DESCRIPTOR); 1137 return queryException; 1138 } 1139 1140 public static QueryException cannotConformUnfetchedAttribute(String attrbuteName) { 1141 Object [] args = { attrbuteName }; 1142 1143 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, CANNOT_CONFORM_UNFETCHED_ATTRIBUTE, args)); 1144 queryException.setErrorCode(CANNOT_CONFORM_UNFETCHED_ATTRIBUTE); 1145 return queryException; 1146 } 1147 1148 public static QueryException fetchGroupAttributeNotMapped(String attrbuteName) { 1149 Object [] args = { attrbuteName }; 1150 1151 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, FETCH_GROUP_ATTRIBUTE_NOT_MAPPED, args)); 1152 queryException.setErrorCode(FETCH_GROUP_ATTRIBUTE_NOT_MAPPED); 1153 return queryException; 1154 } 1155 1156 public static QueryException fetchGroupNotSupportOnReportQuery() { 1157 Object [] args = { }; 1158 1159 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, FETCH_GROUP_NOT_SUPPORT_ON_REPORT_QUERY, args)); 1160 queryException.setErrorCode(FETCH_GROUP_NOT_SUPPORT_ON_REPORT_QUERY); 1161 return queryException; 1162 } 1163 1164 public static QueryException fetchGroupNotSupportOnPartialAttributeReading() { 1165 Object [] args = { }; 1166 1167 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, FETCH_GROUP_NOT_SUPPORT_ON_PARTIAL_ATTRIBUTE_READING, args)); 1168 queryException.setErrorCode(FETCH_GROUP_NOT_SUPPORT_ON_PARTIAL_ATTRIBUTE_READING); 1169 return queryException; 1170 } 1171 1172 public static QueryException fetchGroupValidOnlyIfFetchGroupManagerInDescriptor(String descriptorName, String queryName) { 1173 Object [] args = { descriptorName, queryName }; 1174 1175 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, FETCHGROUP_VALID_ONLY_IF_FETCHGROUP_MANAGER_IN_DESCRIPTOR, args)); 1176 queryException.setErrorCode(FETCHGROUP_VALID_ONLY_IF_FETCHGROUP_MANAGER_IN_DESCRIPTOR); 1177 return queryException; 1178 } 1179 1180 public static QueryException reflectiveCallOnTopLinkClassFailed(String className, Exception e) { 1181 Object [] args = { className }; 1182 1183 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REFLECTIVE_CALL_ON_TOPLINK_CLASS_FAILED, args)); 1184 queryException.setErrorCode(REFLECTIVE_CALL_ON_TOPLINK_CLASS_FAILED); 1185 queryException.setInternalException(e); 1186 return queryException; 1187 } 1188 1189 public static QueryException refreshNotPossibleWithCheckCacheOnly(DatabaseQuery query) { 1190 Object [] args = { }; 1191 1192 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, REFRESH_NOT_POSSIBLE_WITH_CHECK_CACHE_ONLY, args), query); 1193 queryException.setErrorCode(REFRESH_NOT_POSSIBLE_WITH_CHECK_CACHE_ONLY); 1194 return queryException; 1195 } 1196 1197 public static QueryException deleteAllQuerySpecifiesObjectsButNotSelectionCriteria(ClassDescriptor descriptor, DatabaseQuery query, String objects) { 1198 Object [] args = { descriptor.toString(), CR, objects }; 1199 1200 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, DELETE_ALL_QUERY_SPECIFIES_OBJECTS_BUT_NOT_SELECTION_CRITERIA, args), query); 1201 queryException.setErrorCode(DELETE_ALL_QUERY_SPECIFIES_OBJECTS_BUT_NOT_SELECTION_CRITERIA); 1202 return queryException; 1203 } 1204 1205 public static QueryException updateAllQueryAddUpdateFieldIsNull(DatabaseQuery query) { 1206 Object [] args = { }; 1207 1208 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UPDATE_ALL_QUERY_ADD_UPDATE_FIELD_IS_NULL, args), query); 1209 queryException.setErrorCode(UPDATE_ALL_QUERY_ADD_UPDATE_FIELD_IS_NULL); 1210 return queryException; 1211 } 1212 1213 public static QueryException updateAllQueryAddUpdateDoesNotDefineField(ClassDescriptor descriptor, DatabaseQuery query, String attributeNameOrExpression) { 1214 Object [] args = { descriptor.toString(), CR, attributeNameOrExpression }; 1215 1216 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UPDATE_ALL_QUERY_ADD_UPDATE_DOES_NOT_DEFINE_FIELD, args), query); 1217 queryException.setErrorCode(UPDATE_ALL_QUERY_ADD_UPDATE_DOES_NOT_DEFINE_FIELD); 1218 return queryException; 1219 } 1220 1221 public static QueryException updateAllQueryAddUpdateDefinesWrongField(ClassDescriptor descriptor, DatabaseQuery query, String attributeNameOrExpression, String wrongField) { 1222 Object [] args = { descriptor.toString(), CR, attributeNameOrExpression, wrongField }; 1223 1224 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, UPDATE_ALL_QUERY_ADD_UPDATE_DEFINES_WRONG_FIELD, args), query); 1225 queryException.setErrorCode(UPDATE_ALL_QUERY_ADD_UPDATE_DEFINES_WRONG_FIELD); 1226 return queryException; 1227 } 1228 1229 public static QueryException tempTablesNotSupported(DatabaseQuery query, String platformClassName) { 1230 Object [] args = { platformClassName }; 1231 1232 QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, TEMP_TABLES_NOT_SUPPORTED, args), query); 1233 queryException.setErrorCode(TEMP_TABLES_NOT_SUPPORTED); 1234 return queryException; 1235 } 1236} 1237 | Popular Tags |