package space.nstart.pcp.pcp_stations_service.repository


import jakarta.transaction.Transactional
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 space.nstart.pcp.pcp_stations_service.entity.StationEntity
import java.util.Optional
import java.util.UUID


interface StationRepository : JpaRepository<StationEntity, UUID> {

    fun findByStationId(id : UUID) : Optional<StationEntity>

    @Modifying
    @Transactional
    @Query("DELETE FROM  stations WHERE station_id =:id", nativeQuery = true)
    fun deleteByStationId(@Param("id") id : UUID) : Int

}
