Skip to content

Exceptions and exception handling in orman

ahmetalpbalkan edited this page Jun 5, 2011 · 2 revisions

There are many exceptions can be thrown by framework internals.

The exception hierarchy is like:

java.lang.RuntimeException
|
+-- OrmanException
  |
  +---OrmanDatasourceException
  |  |
  |  +--- DatasourceConnectionException
  |  +--- QueryExecutionException
  +---OrmanQueryBuilderException
  |  |
  |  +--- DuplicateSubclauseException
  |  +--- NoTableSpecifiedException
  |  +--- QueryTypeNotImplementedException
  +---FeatureNotImplementedException
  +---OrmanMappingException
  |  |
  |  +---  AnnotatedClassNotFoundInPackageException
  |  +---  DuplicateColumnNamesException
  |  +---  DuplicateTableNamesException
  |  +---  EntityNotFoundException
  |  +---  FieldNotFoundException
  |  +---  IndexNotFoundException
  |  +---  MappingSessionAlreadyStartedException
  |  +---  MappingSessionNotStartedException
  |  +---  NoDatabaseRegisteredException
  |  +---  NotAnEntityException
  |  +---  NotDeclaredDefaultConstructorException
  |  +---  NotDeclaredGetterException
  |  +---  NotDeclaredIdException
  |  +---  NotDeclaredSetterException
  |  +---  NotNullableFieldException
  |  +---  RedundantPrimaryKeyException
  |  +---  TooManyIdException
  |  +---  UnableToPersistDetachedEntityException
  |  +---  UnableToSaveDetachedInstanceAsFieldException
  |  +---  UnannotatedCollectionFieldException
  |  +---  UnmappedDataTypeException
  |  +---  UnmappedEntityException
  |  +---  UnmappedFieldException
  |  +---  UnparametrizedCollectionFieldException
  |  +---  UnregisteredEntityException
  |  +---  UnsolvableDependencyOrderException
  |  +---  UnsupportedPrimaryKeyFieldTypeException
  |_______________________________________________________

You can encounter many OrmanMappingExceptions just after starting the mapping session. You should not catch them and fix errors in your schema to make mapping work correctly.

On the other hand, DatasourceConnectionException means there is a problem with connecting the database and QueryExecutionException means that there is a problem with executing given SQL query on database or established database connection (after establishing it once). You can catch them and make user try again later.