package de.effigenix.infrastructure.production.persistence.repository;

import de.effigenix.infrastructure.production.persistence.entity.BatchNumberSequenceEntity;
import jakarta.persistence.LockModeType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;

import java.time.LocalDate;
import java.util.Optional;

public interface BatchNumberSequenceJpaRepository extends JpaRepository<BatchNumberSequenceEntity, LocalDate> {

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    Optional<BatchNumberSequenceEntity> findByProductionDate(LocalDate productionDate);
}
