return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByName").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).getSingleResult();
} else {
return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByNameWithUser").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).setParameter("userParam", mailboxPath.getUser()).getSingleResult();
}
} catch (NoResultException e) {
throw new MailboxNotFoundException(mailboxPath);
} catch (PersistenceException e) {
throw new MailboxException("Search of mailbox " + mailboxPath + " failed", e);
}
}