Package org.hibernate

Examples of org.hibernate.HibernateException


  public void setParameterValues(Properties parameters) {
    String enumClassName = parameters.getProperty("enumClassName");
    try {
      enumClass = Class.forName(enumClassName).asSubclass(Enum.class);
    } catch (ClassNotFoundException cfne) {
      throw new HibernateException("Enum class not found", cfne);
    }

    String identifierMethodName = parameters.getProperty("identifierMethod", DEFAULT_IDENTIFIER_METHOD_NAME);

    try {
      identifierMethod = enumClass.getMethod(identifierMethodName, new Class[0]);
      identifierType = identifierMethod.getReturnType();
    } catch (Exception a_th) {
      throw new HibernateException("Failed to obtain identifier method", a_th);
    }

    type = (NullableType) TypeFactory.basic(identifierType.getName());

    if (type == null) {
      throw new HibernateException("Unsupported identifier type " + identifierType.getName());
    }

    sqlTypes = new int[] { type.sqlType() };

    String valueOfMethodName = parameters.getProperty("valueOfMethod", DEFAULT_VALUE_OF_METHOD_NAME);

    try {
      valueOfMethod = enumClass.getMethod(valueOfMethodName, new Class[] { identifierType });
    } catch (Exception a_th) {
      throw new HibernateException("Failed to obtain valueOf method", a_th);
    }
  }
View Full Code Here


    }

    try {
      return valueOfMethod.invoke(enumClass, new Object[] { identifier });
    } catch (Exception a_th) {
      throw new HibernateException("Exception while invoking " + "valueOf method '" + valueOfMethod.getName() + "' of " + "enumeration class '" + enumClass + "'", a_th);
    }
  }
View Full Code Here

      } else {
        Object identifier = identifierMethod.invoke(value, new Object[0]);
        type.set(st, identifier, index);
      }
    } catch (Exception a_th) {
      throw new HibernateException("Exception while invoking " + "identifierMethod '" + identifierMethod.getName() + "' of " + "enumeration class '" + enumClass + "'", a_th);
    }
  }
View Full Code Here

          sessionFactory = cfg.buildSessionFactory();
        }
      } catch (Exception a_th) {
        a_th.printStackTrace();
        // log.error(a_th);
        throw new HibernateException("Could not initialize the Hibernate configuration : " + a_th.getMessage(), a_th);
      }
    }
  }
View Full Code Here

      //stop timeout manager, the iterator pace is in the user's hands
      timeoutManager.stop();
      return new IteratorImpl( infos, loader );
    }
    catch ( IOException e ) {
      throw new HibernateException( "Unable to query Lucene index", e );
    }
    finally {
      try {
        closeSearcher( searcher.getSearcher(), searchFactoryImplementor.getReaderProvider() );
      }
View Full Code Here

        closeSearcher( searcher.getSearcher(), searchFactoryImplementor.getReaderProvider() );
      }
      catch ( SearchException ee ) {
        //we have the initial issue already
      }
      throw new HibernateException( "Unable to query Lucene index", e );
    }
  }
View Full Code Here

      else {
        return resultTransformer.transformList( list );
      }
    }
    catch ( IOException e ) {
      throw new HibernateException( "Unable to query Lucene index", e );
    }
    finally {
      try {
        closeSearcher( searcher.getSearcher(), searchFactoryImplementor.getReaderProvider() );
      }
View Full Code Here

      org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
      buildFilters();
      explanation = searcher.getSearcher().explain( query, documentId );
    }
    catch ( IOException e ) {
      throw new HibernateException( "Unable to query Lucene index and build explanation", e );
    }
    finally {
      //searcher cannot be null
      try {
        closeSearcher( searcher.getSearcher(), searchFactoryImplementor.getReaderProvider() );
View Full Code Here

    //TODO check if caching this work for the last n list of indexedTargetedEntities makes a perf boost
    if ( indexedTargetedEntities.size() == 0 ) {
      // empty indexedTargetedEntities array means search over all indexed enities,
      // but we have to make sure there is at least one
      if ( builders.isEmpty() ) {
        throw new HibernateException(
            "There are no mapped entities. Don't forget to add @Indexed to at least one class."
        );
      }

      for ( DocumentBuilderIndexedEntity builder : builders.values() ) {
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        populateDirectories( targetedDirectories, builder );
      }
      classesAndSubclasses = null;
    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        DocumentBuilderIndexedEntity<?> builder = builders.get( clazz );
        if ( builder != null ) {
          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
View Full Code Here

  private Similarity checkSimilarity(Similarity similarity, DocumentBuilderIndexedEntity builder) {
    if ( similarity == null ) {
      similarity = builder.getSimilarity();
    }
    else if ( !similarity.getClass().equals( builder.getSimilarity().getClass() ) ) {
      throw new HibernateException(
          "Cannot perform search on two entities with differing Similarity implementations (" + similarity.getClass()
              .getName() + " & " + builder.getSimilarity().getClass().getName() + ")"
      );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.HibernateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.