use of org.hibernate.query.sqm.InterpretationException in project hibernate-orm by hibernate.
the class StandardHqlTranslator method translate.
@Override
public <R> SqmStatement<R> translate(String query) {
HqlLogging.QUERY_LOGGER.debugf("HQL : " + query);
final HqlParser.StatementContext hqlParseTree = parseHql(query);
// then we perform semantic analysis and build the semantic representation...
try {
final SqmStatement<R> sqmStatement = SemanticQueryBuilder.buildSemanticModel(hqlParseTree, sqmCreationOptions, sqmCreationContext);
// Log the SQM tree (if enabled)
SqmTreePrinter.logTree(sqmStatement);
return sqmStatement;
} catch (QueryException e) {
throw e;
} catch (Exception e) {
throw new InterpretationException(query, e);
}
}
use of org.hibernate.query.sqm.InterpretationException in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method visitTreatedPath.
@Override
public Expression visitTreatedPath(SqmTreatedPath<?, ?> sqmTreatedPath) {
prepareReusablePath(sqmTreatedPath, () -> null);
final TableGroup resolved = getFromClauseAccess().findTableGroup(sqmTreatedPath.getNavigablePath());
if (resolved != null) {
log.tracef("SqmTreatedPath [%s] resolved to existing TableGroup [%s]", sqmTreatedPath, resolved);
return visitTableGroup(resolved, (SqmFrom<?, ?>) sqmTreatedPath);
}
throw new InterpretationException("SqmTreatedPath not yet resolved to TableGroup");
}
use of org.hibernate.query.sqm.InterpretationException in project hibernate-orm by hibernate.
the class ExceptionConverterImpl method convert.
@Override
public RuntimeException convert(HibernateException exception, LockOptions lockOptions) {
if (exception instanceof StaleStateException) {
final PersistenceException converted = wrapStaleStateException((StaleStateException) exception);
handlePersistenceException(converted);
return converted;
} else if (exception instanceof LockAcquisitionException) {
final PersistenceException converted = wrapLockException(exception, lockOptions);
handlePersistenceException(converted);
return converted;
} else if (exception instanceof LockingStrategyException) {
final PersistenceException converted = wrapLockException(exception, lockOptions);
handlePersistenceException(converted);
return converted;
} else if (exception instanceof org.hibernate.PessimisticLockException) {
final PersistenceException converted = wrapLockException(exception, lockOptions);
handlePersistenceException(converted);
return converted;
} else if (exception instanceof org.hibernate.QueryTimeoutException) {
final QueryTimeoutException converted = new QueryTimeoutException(exception.getMessage(), exception);
handlePersistenceException(converted);
return converted;
} else if (exception instanceof ObjectNotFoundException) {
final EntityNotFoundException converted = new EntityNotFoundException(exception.getMessage());
handlePersistenceException(converted);
return converted;
} else if (exception instanceof org.hibernate.NonUniqueObjectException) {
final EntityExistsException converted = new EntityExistsException(exception.getMessage());
handlePersistenceException(converted);
return converted;
} else if (exception instanceof org.hibernate.NonUniqueResultException) {
final NonUniqueResultException converted = new NonUniqueResultException(exception.getMessage());
handlePersistenceException(converted);
return converted;
} else if (exception instanceof UnresolvableObjectException) {
final EntityNotFoundException converted = new EntityNotFoundException(exception.getMessage());
handlePersistenceException(converted);
return converted;
} else if (exception instanceof SemanticException) {
return new IllegalArgumentException(exception);
} else if (exception instanceof QueryException) {
return new IllegalArgumentException(exception);
} else if (exception instanceof InterpretationException) {
return new IllegalArgumentException(exception);
} else if (exception instanceof ParsingException) {
return new IllegalArgumentException(exception);
} else if (exception instanceof MultipleBagFetchException) {
return new IllegalArgumentException(exception);
} else if (exception instanceof TransientObjectException) {
try {
sharedSessionContract.markForRollbackOnly();
} catch (Exception ne) {
// we do not want the subsequent exception to swallow the original one
log.unableToMarkForRollbackOnTransientObjectException(ne);
}
// Spec 3.2.3 Synchronization rules
return new IllegalStateException(exception);
} else {
final PersistenceException converted = new PersistenceException("Converting `" + exception.getClass().getName() + "` to JPA `PersistenceException` : " + exception.getMessage(), exception);
handlePersistenceException(converted);
return converted;
}
}
Aggregations