package com.jasamedika.medifirst2000.dao;

import javax.persistence.LockModeType;

import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.RunningNumber;

@Repository("RunningNumberDao")
public interface RunningNumberDao extends PagingAndSortingRepository<RunningNumber, Integer> {
	 @Lock(LockModeType.PESSIMISTIC_WRITE)
	 public RunningNumber findByResetAndKegunaan(String reset,String kegunaan);
	 
	 @Query("select r.nomerTerbaru from RunningNumber r where r.kegunaan=:kegunaan")
	 public Integer lastNumber(@Param("kegunaan") String kegunaan);
	 
	 @Query("select r.extention from RunningNumber r where r.kegunaan=:kegunaan")
	 public String pasienBayi(@Param("kegunaan") String kegunaan);
}
