use of org.apache.deltaspike.data.impl.meta.RepositoryMethodMetadata in project deltaspike by apache.
the class CdiQueryContextHolderTest method dummyRepoMethod.
private RepositoryMethodMetadata dummyRepoMethod(RepositoryMetadata metadata) {
RepositoryMethodMetadata methodMetadata = new RepositoryMethodMetadata(dummyMethod());
methodMetadata.setMethodPrefix(new RepositoryMethodPrefix(metadata.getRepositoryClass().getAnnotation(Repository.class).methodPrefix(), dummyMethod().getName()));
return methodMetadata;
}
use of org.apache.deltaspike.data.impl.meta.RepositoryMethodMetadata in project deltaspike by apache.
the class QueryHandler method process.
public Object process(Object proxy, Method method, Object[] args) throws Throwable {
CdiQueryInvocationContext queryContext = null;
EntityManagerRef entityManagerRef = null;
try {
List<Class<?>> candidates = ProxyUtils.getProxyAndBaseTypes(proxy.getClass());
RepositoryMetadata repositoryMetadata = metadataHandler.lookupComponent(candidates);
RepositoryMethodMetadata repositoryMethodMetadata = metadataHandler.lookupMethod(repositoryMetadata, method);
entityManagerRef = entityManagerRefLookup.lookupReference(repositoryMetadata);
queryContext = createContext(proxy, method, args, entityManagerRef.getEntityManager(), repositoryMetadata, repositoryMethodMetadata);
QueryBuilder builder = queryBuilderFactory.build(repositoryMethodMetadata, queryContext);
Object result = runner.executeQuery(builder, queryContext);
return result;
} catch (PersistenceException e) {
throw e;
} catch (Exception e) {
log.log(Level.FINEST, "Query execution error", e);
if (queryContext != null) {
throw new QueryInvocationException(e, queryContext);
}
throw new QueryInvocationException(e, proxy.getClass(), method);
} finally {
if (entityManagerRef != null) {
entityManagerRef.release();
}
context.dispose();
}
}
Aggregations