class HostComponentDesiredStateDAO {

  @Transactional
  public void remove(HostComponentDesiredStateEntity hostComponentDesiredStateEntity) {
    HostEntity hostEntity = hostComponentDesiredStateEntity.getHostEntity();

    if (hostEntity == null) {
      throw new IllegalStateException(String.format("Missing hostEntity for host id %1d",
              hostComponentDesiredStateEntity.getHostId()));
    }

    hostEntity.removeHostComponentDesiredStateEntity(hostComponentDesiredStateEntity);

    entityManagerProvider.get().remove(hostComponentDesiredStateEntity);
    hostDAO.merge(hostEntity);
  }

}