package de.votian.services.repository;

import de.votian.services.entity.EmployeeCostCenter;
import de.votian.services.entity.EmployeeCostCenterId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface EmployeeCostCenterRepository extends JpaRepository<EmployeeCostCenter, EmployeeCostCenterId> {

    List<EmployeeCostCenter> findByEmployeeIdOrderByCostCenterIdAsc(Long employeeId);

    @Modifying
    @Query("DELETE FROM EmployeeCostCenter ecc WHERE ecc.employeeId = :empId")
    void deleteByEmployeeId(@Param("empId") Long employeeId);
}
