@Transactional
  void persistEntities(HostEntity hostEntity, HostComponentStateEntity stateEntity,
                       HostComponentDesiredStateEntity desiredStateEntity,
                       ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {

    if (serviceComponentDesiredStateEntity == null) {
      serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.findByName(
          serviceComponent.getClusterId(), serviceComponent.getServiceName(), serviceComponent.getName());
    }

    desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    desiredStateEntity.setHostEntity(hostEntity);
    desiredStateEntity.setHostId(hostEntity.getHostId());

    stateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    stateEntity.setHostEntity(hostEntity);

    hostComponentStateDAO.create(stateEntity);
    hostComponentDesiredStateDAO.create(desiredStateEntity);

    serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(
        desiredStateEntity);

    serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.merge(
        serviceComponentDesiredStateEntity);

    hostEntity.addHostComponentStateEntity(stateEntity);
    hostEntity.addHostComponentDesiredStateEntity(desiredStateEntity);
    hostEntity = hostDAO.merge(hostEntity);
  }
@param lastOpLastUpdateTime the lastOpLastUpdateTime to set
ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java