jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds-labs] JCLOUDS-826: Add blob operations (#176)
Date Thu, 11 Jun 2015 08:07:53 GMT
>  
>     @Inject
>     private ContainerRepository(Provider<EntityManager> entityManager) {
>        super(entityManager);
>     }
>  
> -   public Container findContainerByName(String name) {
> -      return entityManager.get().createQuery("SELECT c FROM " + entityClass.getName()
+ " c WHERE c.name = :name", entityClass)
> -            .setParameter("name", name)
> -            .getSingleResult();
> +   public ContainerEntity findContainerByName(String name) {
> +      try {
> +         return entityManager.get().createQuery("SELECT c FROM " + entityClass.getName()
+ " c WHERE c.name = :name", entityClass)
> +               .setParameter("name", name)
> +               .getSingleResult();
> +      } catch (PersistenceException e) {
> +         return null;

You'd better just catch the `NoResultException` to return null and propagate the exception
otherwise.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/176/files#r32197920
Mime
View raw message