package com.oguerreiro.resilient.repository.impl;

import org.hibernate.LockMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.oguerreiro.resilient.domain.InputDataUpload;
import com.oguerreiro.resilient.repository.InputDataUploadRepositoryEntended;

import jakarta.persistence.EntityManager;

@Repository
public class InputDataUploadRepositoryEntendedImpl implements InputDataUploadRepositoryEntended {
    @Autowired
    private EntityManager entityManager;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public InputDataUpload updateInNewTransaction(InputDataUpload inputDataUpload) {
        // Persist the entity in a new transaction
    	inputDataUpload = entityManager.merge(inputDataUpload);
    	return inputDataUpload;
    }

}
