@Override
  @Transactional
  public Image loadImage(long id) {
    Image image = entityManager.find(Image.class, id);

    if (image != null) {
      // Need this to load domain properties collection
      image.getDomainProperties().size();
    }

    return image;
  }
 @Override
 @Transactional
 public void deleteImage(Image image) {
   Image loadedImage = entityManager.find(Image.class, image.getId());
   if (loadedImage != null) {
     entityManager.remove(loadedImage);
   }
 }
  @Override
  @Transactional
  public List<Image> loadImages(SearchCriteria searchCriteria) {

    CriteriaQuery<Image> criteriaQuery =
        criteriaSearchHelper.createSearchImagesCriteria(searchCriteria);

    TypedQuery<Image> query = entityManager.createQuery(criteriaQuery);
    query.setFirstResult(0);
    query.setMaxResults(maxImagesPerQuery);

    List<Image> result = query.getResultList();
    if (result != null) {
      for (Image image : result) {
        // Need this to load domain properties collection
        image.getDomainProperties().size();
      }
    }

    return result;
  }