@Override public boolean delete(IService service) { try { service = entityManager.getReference(Service.class, service.getId()); entityManager.remove(service); entityManager.flush(); return true; } catch (EntityNotFoundException e) { logger.debug("Service[{}] not found", service.getId()); return false; } }
@Override public IService getByUUID(String uuid) { try { Query query = entityManager.createNamedQuery(Service.QUERY_FIND_BY_UUID); query.setParameter("uuid", uuid); IService service = new Service(); service = (Service) query.getSingleResult(); System.out.println("Service name:" + service.getName()); return service; } catch (NoResultException e) { logger.debug("No Result found: " + e); return null; } }
@Override public IService getByName(String name) { try { TypedQuery<IService> query = entityManager.createNamedQuery(Service.QUERY_FIND_BY_NAME, IService.class); query.setParameter("name", name); IService service = new Service(); service = (Service) query.getSingleResult(); System.out.println("Service uuid:" + service.getUuid()); return service; } catch (NoResultException e) { logger.debug("No Result found: " + e); return null; } }