use of javax.persistence.NoResultException in project che by eclipse.
the class JpaWorkspaceDao method get.
@Override
@Transactional
public WorkspaceImpl get(String name, String namespace) throws NotFoundException, ServerException {
requireNonNull(name, "Required non-null name");
requireNonNull(namespace, "Required non-null namespace");
try {
return new WorkspaceImpl(managerProvider.get().createNamedQuery("Workspace.getByName", WorkspaceImpl.class).setParameter("namespace", namespace).setParameter("name", name).getSingleResult());
} catch (NoResultException noResEx) {
throw new NotFoundException(format("Workspace with name '%s' in namespace '%s' doesn't exist", name, namespace));
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of javax.persistence.NoResultException in project che by eclipse.
the class JpaAccountDao method getByName.
@Override
@Transactional
public AccountImpl getByName(String name) throws ServerException, NotFoundException {
requireNonNull(name, "Required non-null account name");
final EntityManager manager = managerProvider.get();
try {
return manager.createNamedQuery("Account.getByName", AccountImpl.class).setParameter("name", name).getSingleResult();
} catch (NoResultException e) {
throw new NotFoundException(String.format("Account with name '%s' was not found", name));
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
use of javax.persistence.NoResultException in project hibernate-orm by hibernate.
the class AbstractOneToOneMapper method nullSafeMapToEntityFromMap.
@Override
public void nullSafeMapToEntityFromMap(EnversService enversService, Object obj, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
final EntityInfo referencedEntity = getEntityInfo(enversService, referencedEntityName);
Object value;
try {
value = queryForReferencedEntity(versionsReader, referencedEntity, (Serializable) primaryKey, revision);
} catch (NoResultException e) {
value = null;
} catch (NonUniqueResultException e) {
throw new AuditException("Many versions results for one-to-one relationship " + entityName + "." + getPropertyData().getBeanName() + ".", e);
}
setPropertyValue(obj, value);
}
use of javax.persistence.NoResultException in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method findTblMleByUUID.
public TblMle findTblMleByUUID(String uuid_hex) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblMle.findByUUID_Hex");
query.setParameter("uuid_hex", uuid_hex);
TblMle tblOem = (TblMle) query.getSingleResult();
return tblOem;
} catch (NoResultException e) {
log.error("NoResultException : MLE with UUID {} not found", uuid_hex);
return null;
} finally {
em.close();
}
}
use of javax.persistence.NoResultException in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method findTblModuleManifestByHardwareUuid.
public List<TblModuleManifest> findTblModuleManifestByHardwareUuid(String uuid) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblModuleManifest.findByHardwareUuid");
query.setParameter("uuid_hex", uuid);
List<TblModuleManifest> moduleList = query.getResultList();
return moduleList;
} catch (NoResultException e) {
log.error(String.format("Module information with UUID {} not found in the DB.", uuid));
return null;
} finally {
em.close();
}
}
Aggregations