Search in sources :

Example 1 with DetailedSemanticException

use of org.hibernate.hql.internal.ast.DetailedSemanticException in project hibernate-orm by hibernate.

the class ConstructorNode method resolveConstructor.

private Constructor resolveConstructor(String path) throws SemanticException {
    String importedClassName = getSessionFactoryHelper().getImportedClassName(path);
    String className = StringHelper.isEmpty(importedClassName) ? path : importedClassName;
    if (className == null) {
        throw new SemanticException("Unable to locate class [" + path + "]");
    }
    try {
        final Class holderClass = getSessionFactoryHelper().getFactory().getServiceRegistry().getService(ClassLoaderService.class).classForName(className);
        return ReflectHelper.getConstructor(holderClass, constructorArgumentTypes);
    } catch (ClassLoadingException e) {
        throw new DetailedSemanticException("Unable to locate class [" + className + "]", e);
    } catch (PropertyNotFoundException e) {
        // locate an appropriate constructor
        throw new DetailedSemanticException(formatMissingContructorExceptionMessage(className), e);
    }
}
Also used : PropertyNotFoundException(org.hibernate.PropertyNotFoundException) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) DetailedSemanticException(org.hibernate.hql.internal.ast.DetailedSemanticException) SemanticException(antlr.SemanticException) DetailedSemanticException(org.hibernate.hql.internal.ast.DetailedSemanticException) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Example 2 with DetailedSemanticException

use of org.hibernate.hql.internal.ast.DetailedSemanticException in project hibernate-orm by hibernate.

the class HQLTest method testExceptions.

@Test
public void testExceptions() throws Exception {
    DetailedSemanticException dse = new DetailedSemanticException("test");
    dse.printStackTrace();
    dse.printStackTrace(new PrintWriter(new StringWriter()));
    QuerySyntaxException qse = QuerySyntaxException.convert(new RecognitionException("test"), "from bozo b where b.clown = true");
    assertNotNull(qse.getMessage());
}
Also used : StringWriter(java.io.StringWriter) QuerySyntaxException(org.hibernate.hql.internal.ast.QuerySyntaxException) DetailedSemanticException(org.hibernate.hql.internal.ast.DetailedSemanticException) RecognitionException(antlr.RecognitionException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

DetailedSemanticException (org.hibernate.hql.internal.ast.DetailedSemanticException)2 RecognitionException (antlr.RecognitionException)1 SemanticException (antlr.SemanticException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 PropertyNotFoundException (org.hibernate.PropertyNotFoundException)1 ClassLoaderService (org.hibernate.boot.registry.classloading.spi.ClassLoaderService)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1 QuerySyntaxException (org.hibernate.hql.internal.ast.QuerySyntaxException)1 Test (org.junit.Test)1